Commit 020e773f authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Linus Torvalds

kconfig: sym_expand_string_value: allow for string termination when reallocing

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: default avatarAndy Whitcroft <apw@canonical.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e99d11d1
...@@ -875,7 +875,7 @@ const char *sym_expand_string_value(const char *in) ...@@ -875,7 +875,7 @@ const char *sym_expand_string_value(const char *in)
symval = sym_get_string_value(sym); symval = sym_get_string_value(sym);
} }
newlen = strlen(res) + strlen(symval) + strlen(src); newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
if (newlen > reslen) { if (newlen > reslen) {
reslen = newlen; reslen = newlen;
res = realloc(res, reslen); res = realloc(res, reslen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment