linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sparse: Increase pre_buffer[] and check overflow
@ 2008-07-08 15:28 Atsushi Nemoto
  2008-07-08 15:59 ` Atsushi Nemoto
  2008-07-08 20:45 ` Sam Ravnborg
  0 siblings, 2 replies; 9+ messages in thread
From: Atsushi Nemoto @ 2008-07-08 15:28 UTC (permalink / raw)
  To: linux-sparse; +Cc: linux-mips

I got this error when running sparse on mips kernel with gcc 4.3:

builtin:272:1: warning: Newline in string or character constant

The linus-mips kernel uses '$(CC) -dM -E' to generates arguments for
sparse.  With gcc 4.3, it generates lot of '-D' options and causes
pre_buffer overflow.

This patch increase pre_buffer[] size and add extra checking for
overflow instead of silently truncating.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/lib.c b/lib.c
index 0abcc9a..b8b2d57 100644
--- a/lib.c
+++ b/lib.c
@@ -186,7 +186,7 @@ void die(const char *fmt, ...)
 }
 
 static unsigned int pre_buffer_size;
-static char pre_buffer[8192];
+static char pre_buffer[16384];
 
 int Waddress_space = 1;
 int Wbitwise = 0;
@@ -238,6 +238,8 @@ void add_pre_buffer(const char *fmt, ...)
 		fmt, args);
 	pre_buffer_size = size;
 	va_end(args);
+	if (pre_buffer_size >= sizeof(pre_buffer) - 1)
+		die("pre_buffer overflow");
 }
 
 static char **handle_switch_D(char *arg, char **next)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-07-11 16:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-08 15:28 [PATCH] sparse: Increase pre_buffer[] and check overflow Atsushi Nemoto
2008-07-08 15:59 ` Atsushi Nemoto
2008-07-10 17:51   ` Al Viro
2008-07-10 18:09     ` Morten Welinder
2008-07-08 20:45 ` Sam Ravnborg
2008-07-09 16:18   ` Atsushi Nemoto
2008-07-09 16:32     ` Sam Ravnborg
2008-07-10 17:39       ` Al Viro
2008-07-11 16:07         ` Atsushi Nemoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).