diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:24 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:24 -0800 |
commit | 340c54ae5531ab08022c77cf4a12beb2c420bc24 (patch) | |
tree | 29fd11581603b5bd43e90956ace4bb767cfebf51 /compat | |
parent | ded408fd20e2fedb76850c9fa9bbaa26b888aa7c (diff) | |
parent | 6ac1b2a3b8bd970e9fc175c42927f00d4d465bbf (diff) | |
download | git-340c54ae5531ab08022c77cf4a12beb2c420bc24.tar.gz |
Merge branch 'ef/setenv-putenv'
* ef/setenv-putenv:
compat/setenv.c: error if name contains '='
compat/setenv.c: update errno when erroring out
Diffstat (limited to 'compat')
-rw-r--r-- | compat/setenv.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compat/setenv.c b/compat/setenv.c index 3a22ea7b75..fc1439a643 100644 --- a/compat/setenv.c +++ b/compat/setenv.c @@ -6,7 +6,10 @@ int gitsetenv(const char *name, const char *value, int replace) size_t namelen, valuelen; char *envstr; - if (!name || !value) return -1; + if (!name || strchr(name, '=') || !value) { + errno = EINVAL; + return -1; + } if (!replace) { char *oldval = NULL; oldval = getenv(name); @@ -16,7 +19,10 @@ int gitsetenv(const char *name, const char *value, int replace) namelen = strlen(name); valuelen = strlen(value); envstr = malloc((namelen + valuelen + 2)); - if (!envstr) return -1; + if (!envstr) { + errno = ENOMEM; + return -1; + } memcpy(envstr, name, namelen); envstr[namelen] = '='; |