[Top] [All Lists]

[PATCH] sparse: Increase pre_buffer[] and check overflow

Subject: [PATCH] sparse: Increase pre_buffer[] and check overflow
From: Atsushi Nemoto <>
Date: Wed, 09 Jul 2008 00:28:05 +0900 (JST)
Original-recipient: rfc822;
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 <>
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;
+       if (pre_buffer_size >= sizeof(pre_buffer) - 1)
+               die("pre_buffer overflow");
 static char **handle_switch_D(char *arg, char **next)

<Prev in Thread] Current Thread [Next in Thread>