mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@canonical.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] kconfig: sym_expand_string_value: allow for string termination when reallocing
Date: Mon,  1 Nov 2010 21:01:44 +0000	[thread overview]
Message-ID: <1288645304-2794-2-git-send-email-apw@canonical.com> (raw)
In-Reply-To: <1288645304-2794-1-git-send-email-apw@canonical.com>

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


  reply	other threads:[~2010-11-01 21:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 21:01 [PATCH 0/1] Fix kconfig core dumps running make oldconfig Andy Whitcroft
2010-11-01 21:01 ` Andy Whitcroft [this message]
2010-11-25 14:23   ` [PATCH 1/1] kconfig: sym_expand_string_value: allow for string termination when reallocing Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288645304-2794-2-git-send-email-apw@canonical.com \
    --to=apw@canonical.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®