compat/setenv.c: error if name contains '='
authorErik Faye-Lund <kusmabite@gmail.com>
Wed, 14 Dec 2011 14:07:09 +0000 (15:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 15 Dec 2011 03:31:03 +0000 (19:31 -0800)
According to POSIX, setenv should error out with EINVAL if it's
asked to set an environment variable whose name contains an equals
sign. Implement this detail in our compatibility-fallback.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/setenv.c
index 89947b7134a7671c7f035e48bf8cd5f3ce4bc7c4..fc1439a6439393ff5224e98ab126607ceaa4994d 100644 (file)
@@ -6,7 +6,7 @@ int gitsetenv(const char *name, const char *value, int replace)
        size_t namelen, valuelen;
        char *envstr;
 
-       if (!name || !value) {
+       if (!name || strchr(name, '=') || !value) {
                errno = EINVAL;
                return -1;
        }