]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
kconfig: sym_expand_string_value: allow for string termination when reallocing
authorAndy Whitcroft <apw@canonical.com>
Mon, 1 Nov 2010 21:01:44 +0000 (21:01 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 1 Nov 2010 21:06:00 +0000 (17:06 -0400)
When expanding a parameterised string we may run out of space, this
triggers a realloc.  When computing the new allocation size we do not
allow for the terminating '\0'.  Allow for this when calculating the new
length.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/kconfig/symbol.c

index c0efe102d655c40547afe92014cec1c74b70b3c2..af6e9f3de9503b033a69a3eba7c2ecd212fef747 100644 (file)
@@ -875,7 +875,7 @@ const char *sym_expand_string_value(const char *in)
                        symval = sym_get_string_value(sym);
                }
 
-               newlen = strlen(res) + strlen(symval) + strlen(src);
+               newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
                if (newlen > reslen) {
                        reslen = newlen;
                        res = realloc(res, reslen);