summaryrefslogtreecommitdiff
path: root/src/option.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-31 04:06:51 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-31 04:07:41 -0400
commitd7a06a31aaff7f662718c96eaa4106e3a06f7b40 (patch)
treea729e9cddf100edff3c03f2614037fcb280c4eba /src/option.cc
parent289f1ec0eeaf1d84f2638677ca1e452eeb01ed3d (diff)
downloadfork-ledger-d7a06a31aaff7f662718c96eaa4106e3a06f7b40.tar.gz
fork-ledger-d7a06a31aaff7f662718c96eaa4106e3a06f7b40.tar.bz2
fork-ledger-d7a06a31aaff7f662718c96eaa4106e3a06f7b40.zip
Correct some code in process_environment
Diffstat (limited to 'src/option.cc')
-rw-r--r--src/option.cc9
1 files changed, 6 insertions, 3 deletions
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++ = '-';