From d7a06a31aaff7f662718c96eaa4106e3a06f7b40 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 31 Oct 2009 04:06:51 -0400 Subject: Correct some code in process_environment --- src/option.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/option.cc') diff --git a/src/option.cc b/src/option.cc index 883080e2..8da66b36 100644 --- a/src/option.cc +++ b/src/option.cc @@ -116,13 +116,16 @@ void process_environment(const char ** envp, const string& tag, const char * tag_p = tag.c_str(); string::size_type tag_len = tag.length(); + assert(tag_p); + assert(tag_len > 0); + for (const char ** p = envp; *p; p++) { - if (! tag_p || std::strncmp(*p, tag_p, tag_len) == 0) { - char buf[128]; + if (std::strlen(*p) >= tag_len && std::strncmp(*p, tag_p, tag_len) == 0) { + char buf[8192]; char * r = buf; const char * q; for (q = *p + tag_len; - *q && *q != '=' && r - buf < 128; + *q && *q != '=' && r - buf < 8191; q++) if (*q == '_') *r++ = '-'; -- cgit v1.2.3