[6173] in Moira
Re: Patch to appease compilers using -Werror=format-security
daemon@ATHENA.MIT.EDU (Garry P Zacheiss)
Mon May 7 12:53:27 2012
From: Garry P Zacheiss <zacheiss@MIT.EDU>
To: Jonathan D Reed <jdreed@MIT.EDU>
CC: "<moiradev@mit.edu>" <moiradev@MIT.EDU>
Date: Mon, 7 May 2012 16:53:23 +0000
Message-ID: <25C22396-3494-4EDD-AC36-AEEF6C880561@exchange.mit.edu>
In-Reply-To: <alpine.DEB.2.02.1205031615580.16994@INFINITE-LOOP.MIT.EDU>
Content-Language: en-US
Content-Type: text/plain; charset="us-ascii"
Content-ID: <C0F56635E4C08C4D9FD1BC039BE9F7E9@exchange.mit.edu>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Thanks, committed.
Garry
On May 3, 2012, at 4:17 PM, Jonathan Reed wrote:
> Hi Garry,
>
> Ubuntu 12.04 has -Werror=format-security as a default when building packages, and as a result Moira failed to build from source. We made the following changes. Would you be willing to take them upstream?
>
> Thanks,
>
> Jon
>
> Index: update/update_server.c
> ===================================================================
> --- update/update_server.c (revision 4076)
> +++ update/update_server.c (working copy)
> @@ -227,7 +227,7 @@
>
> void fail(int conn, int err, char *msg)
> {
> - com_err(whoami, err, msg);
> + com_err(whoami, err, "%s", msg);
> close(conn);
> exit(1);
> }
> Index: update/client.c
> ===================================================================
> --- update/client.c (revision 4076)
> +++ update/client.c (working copy)
> @@ -169,6 +169,6 @@
>
> void fail(int conn, int err, char *msg)
> {
> - com_err(whoami, err, msg);
> + com_err(whoami, err, "%s", msg);
> return;
> }
> Index: clients/moira/attach.c
> ===================================================================
> --- clients/moira/attach.c (revision 4076)
> +++ clients/moira/attach.c (working copy)
> @@ -188,7 +188,7 @@
>
> static char *GetFSLabel(char **info)
> {
> - snprintf(labelbuf, sizeof(labelbuf), info[ALIAS_TRANS]);
> + snprintf(labelbuf, sizeof(labelbuf), "%s", info[ALIAS_TRANS]);
> }
>
> static int fsgCount = 1;
> Index: clients/moira/main.c
> ===================================================================
> --- clients/moira/main.c (revision 4076)
> +++ clients/moira/main.c (working copy)
> @@ -169,7 +169,7 @@
>
> static void ErrorExit(char *buf, int status)
> {
> - com_err(program_name, status, buf);
> + com_err(program_name, status, "%s", buf);
> mr_disconnect();
> exit(1);
> }
> Index: clients/moira/namespace.c
> ===================================================================
> --- clients/moira/namespace.c (revision 4076)
> +++ clients/moira/namespace.c (working copy)
> @@ -293,7 +293,7 @@
>
> static void ErrorExit(char *buf, int status)
> {
> - com_err(program_name, status, buf);
> + com_err(program_name, status, "%s", buf);
> mr_disconnect();
> exit(1);
> }
> Index: clients/mailmaint/mailmaint.c
> ===================================================================
> --- clients/mailmaint/mailmaint.c (revision 4076)
> +++ clients/mailmaint/mailmaint.c (working copy)
> @@ -216,7 +216,7 @@
> exit(0);
>
> punt:
> - com_err(whoami, status, buf);
> + com_err(whoami, status, "%s", buf);
> exit(1);
> }
>
> Index: clients/mrcheck/mrcheck.c
> ===================================================================
> --- clients/mrcheck/mrcheck.c (revision 4076)
> +++ clients/mrcheck/mrcheck.c (working copy)
> @@ -224,7 +224,7 @@
> exit(0);
>
> punt:
> - com_err(whoami, status, buf);
> + com_err(whoami, status, "%s", buf);
> mr_disconnect();
> exit(1);
> }
> Index: clients/mrtest/mrtest.c
> ===================================================================
> --- clients/mrtest/mrtest.c (revision 4076)
> +++ clients/mrtest/mrtest.c (working copy)
> @@ -372,8 +372,7 @@
> inp = fopen(argv[1], "r");
> if (!inp)
> {
> - sprintf(input, "Cannot open input file %s", argv[1]);
> - com_err("moira (script)", 0, input);
> + com_err("moira (script)", 0, "Cannot open input file %s", argv[1]);
> return;
> }
>
> @@ -389,8 +388,7 @@
> close(status);
> dup2(oldstdout, 1);
> argc = 2;
> - sprintf(input, "Unable to redirect output to %s\n", argv[2]);
> - com_err("moira (script)", errno, input);
> + com_err("moira (script)", errno, "Unable to redirect output to %s\n", argv[2]);
> }
> else
> {
> Index: lib/critical.c
> ===================================================================
> --- lib/critical.c (revision 4076)
> +++ lib/critical.c (working copy)
> @@ -73,7 +73,7 @@
> va_end(ap);
>
> send_zgram(instance, buf);
> - com_err(whoami, 0, buf);
> + com_err(whoami, 0, "%s", buf);
>
> free(buf);
> }