* [PATCH] strncpy() will not \0 terminate result
@ 2011-01-13 22:35 Jesper Juhl
2011-01-13 22:46 ` Wolfram Sang
2011-01-14 0:25 ` Tony Finch
0 siblings, 2 replies; 5+ messages in thread
From: Jesper Juhl @ 2011-01-13 22:35 UTC (permalink / raw)
To: Tony Finch; +Cc: linux-kernel
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.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] strncpy() will not \0 terminate result
2011-01-13 22:35 [PATCH] strncpy() will not \0 terminate result Jesper Juhl
@ 2011-01-13 22:46 ` Wolfram Sang
2011-01-13 22:48 ` Jesper Juhl
2011-01-14 0:25 ` Tony Finch
1 sibling, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2011-01-13 22:46 UTC (permalink / raw)
To: Jesper Juhl; +Cc: Tony Finch, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
On Thu, Jan 13, 2011 at 11:35:39PM +0100, Jesper Juhl 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>
Thanks for fixing those issues. If you could spend a few more seconds on the
subject line (missing sth like "scripts/unifdef"-prefix; I initially was
fearing the bug was in lib/string.c) and the commit-message (which reads like a
mail), that would be helpful for reviewers.
Kind regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] strncpy() will not \0 terminate result
2011-01-13 22:46 ` Wolfram Sang
@ 2011-01-13 22:48 ` Jesper Juhl
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2011-01-13 22:48 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Tony Finch, linux-kernel
On Thu, 13 Jan 2011, Wolfram Sang wrote:
> On Thu, Jan 13, 2011 at 11:35:39PM +0100, Jesper Juhl 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>
>
> Thanks for fixing those issues. If you could spend a few more seconds on the
> subject line (missing sth like "scripts/unifdef"-prefix; I initially was
> fearing the bug was in lib/string.c) and the commit-message (which reads like a
> mail), that would be helpful for reviewers.
>
Yeah, I don't know what happened when I wrote that subject - it's quite
bad. Sorry.
--
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] strncpy() will not \0 terminate result
2011-01-13 22:35 [PATCH] strncpy() will not \0 terminate result Jesper Juhl
2011-01-13 22:46 ` Wolfram Sang
@ 2011-01-14 0:25 ` Tony Finch
2011-01-16 14:07 ` Jesper Juhl
1 sibling, 1 reply; 5+ messages in thread
From: Tony Finch @ 2011-01-14 0:25 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel
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.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-16 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-13 22:35 [PATCH] strncpy() will not \0 terminate result Jesper Juhl
2011-01-13 22:46 ` Wolfram Sang
2011-01-13 22:48 ` Jesper Juhl
2011-01-14 0:25 ` Tony Finch
2011-01-16 14:07 ` Jesper Juhl
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®