diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-28 20:42:24 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-28 20:42:24 +0100 |
commit | e8f6b51a6bcc904b8a5fed831f718c3f9ed7ef34 (patch) | |
tree | 0a87f73f957e38ac804899b2cbd67bfe0b977a3a | |
parent | Merge branch 'jc/advice-doc' into maint (diff) | |
parent | compat/setenv.c: error if name contains '=' (diff) | |
download | git-e8f6b51a6bcc904b8a5fed831f718c3f9ed7ef34.tar.xz git-e8f6b51a6bcc904b8a5fed831f718c3f9ed7ef34.zip |
Merge branch 'ef/setenv-putenv' into maint
* ef/setenv-putenv:
compat/setenv.c: error if name contains '='
compat/setenv.c: update errno when erroring out
-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] = '='; |