mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [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

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®