From: Tony Finch <dot@dotat.at>
To: Jesper Juhl <jj@chaosbits.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] strncpy() will not \0 terminate result
Date: Fri, 14 Jan 2011 00:25:17 +0000 [thread overview]
Message-ID: <0203A9B5-3035-49A1-AAB7-207EB638A080@dotat.at> (raw)
In-Reply-To: <alpine.LNX.2.00.1101132332430.11347@swampdragon.chaosbits.net>
This patch is incorrect. The strncpy is replacing "else" with "if " so needs to copy exactly 4 bytes.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
On 13 Jan 2011, at 22:35, Jesper Juhl <jj@chaosbits.net> wrote:
> Hi,
>
> Mpass() in scripts/unifdef.c has this code:
> strncpy(keyword, "if ", 4);
> this will fail to \0 terminate the destination.
> Following patch should fix that up.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> unifdef.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/unifdef.c b/scripts/unifdef.c
> index 44d3978..d579249 100644
> --- a/scripts/unifdef.c
> +++ b/scripts/unifdef.c
> @@ -376,7 +376,7 @@ static void Idrop (void) { Fdrop(); ignoreon(); }
> static void Itrue (void) { Ftrue(); ignoreon(); }
> static void Ifalse(void) { Ffalse(); ignoreon(); }
> /* edit this line */
> -static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); }
> +static void Mpass (void) { strncpy(keyword, "if ", 5); Pelif(); }
> static void Mtrue (void) { keywordedit("else\n"); state(IS_TRUE_MIDDLE); }
> static void Melif (void) { keywordedit("endif\n"); state(IS_FALSE_TRAILER); }
> static void Melse (void) { keywordedit("endif\n"); state(IS_FALSE_ELSE); }
>
> --
> Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please.
>
next prev parent reply other threads:[~2011-01-14 0:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-13 22:35 Jesper Juhl
2011-01-13 22:46 ` Wolfram Sang
2011-01-13 22:48 ` Jesper Juhl
2011-01-14 0:25 ` Tony Finch [this message]
2011-01-16 14:07 ` Jesper Juhl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0203A9B5-3035-49A1-AAB7-207EB638A080@dotat.at \
--to=dot@dotat.at \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®