NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/45660: Overlapping buffer in catman.c.
The following reply was made to PR bin/45660; it has been noted by GNATS.
From: henning petersen <henning.petersen%t-online.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: bin/45660: Overlapping buffer in catman.c.
Date: Mon, 05 Dec 2011 11:14:08 +0100
This is a multi-part message in MIME format.
--------------030105010608030801060308
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
Am 27.11.2011 14:35, schrieb Christian Biere:
> The following reply was made to PR bin/45660; it has been noted by GNATS.
>
> From: Christian Biere <christianbiere%gmx.de@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Cc:
> Subject: Re: bin/45660: Overlapping buffer in catman.c.
> Date: Sun, 27 Nov 2011 14:33:18 +0100
>
> I assume the missing constant format string argument at the first
> snprintf() in makecat() is actually a bug. I'm sure the compiler
> is warning about this.
>
> Therefore, I propose the following patch instead.
>
> --- catman.c.orig 2011-11-27 14:27:47.788003030 +0100
> +++ catman.c 2011-11-27 14:27:32.728003016 +0100
> @@ -559,16 +559,17 @@ static void
> makecat(const char *manpage, const char *catpage, const char *buildcmd,
> const char *crunchcmd)
> {
> - char crunchbuf[1024];
> char sysbuf[2048];
>
> - snprintf(sysbuf, sizeof(sysbuf), buildcmd, manpage);
> -
> if (*crunchcmd != '\0') {
> + char crunchbuf[1024];
> +
> snprintf(crunchbuf, sizeof(crunchbuf), crunchcmd, catpage);
> - snprintf(sysbuf, sizeof(sysbuf), "%s | %s", sysbuf, crunchbuf);
> + snprintf(sysbuf, sizeof(sysbuf), "%s%s | %s",
> + buildcmd, manpage, crunchbuf);
> } else {
> - snprintf(sysbuf, sizeof(sysbuf), "%s > %s", sysbuf, catpage);
> + snprintf(sysbuf, sizeof(sysbuf), "%s%s > %s",
> + buildcmd, manpage, catpage);
> }
>
> if (f_noprint == 0)
>
>
>
OK Attach is the new patch.
--------------030105010608030801060308
Content-Type: text/plain;
name="catman.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="catman.c.diff"
diff -u -p -r1.30 catman.c
--- usr.sbin/catman/catman.c 29 Aug 2011 20:38:55 -0000 1.30
+++ usr.sbin/catman/catman.c 27 Nov 2011 17:51:36 -0000
@@ -559,16 +559,16 @@ static void
makecat(const char *manpage, const char *catpage, const char *buildcmd,
const char *crunchcmd)
{
- char crunchbuf[1024];
char sysbuf[2048];
- snprintf(sysbuf, sizeof(sysbuf), buildcmd, manpage);
-
if (*crunchcmd != '\0') {
+ char crunchbuf[1024];
snprintf(crunchbuf, sizeof(crunchbuf), crunchcmd, catpage);
- snprintf(sysbuf, sizeof(sysbuf), "%s | %s", sysbuf, crunchbuf);
+ snprintf(sysbuf, sizeof(sysbuf), "%s%s | %s",
+ buildcmd, manpage, crunchbuf);
} else {
- snprintf(sysbuf, sizeof(sysbuf), "%s > %s", sysbuf, catpage);
+ snprintf(sysbuf, sizeof(sysbuf), "%s%s > %s",
+ buildcmd, manpage, catpage);
}
if (f_noprint == 0)
--------------030105010608030801060308--
Home |
Main Index |
Thread Index |
Old Index