lkml.org 
[lkml]   [2010]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] kconfig: sym_expand_string_value: allow for string termination when reallocing
Date
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>
---
scripts/kconfig/symbol.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index c0efe10..af6e9f3 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -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);
--
1.7.1


\
 
 \ /
  Last update: 2010-11-01 22:05    [W:0.273 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site