Merge branch 'mf/no-dashed-subcommands' into maint
[gitweb.git] / compat / setenv.c
index 89947b7134a7671c7f035e48bf8cd5f3ce4bc7c4..7849f258d20195ac27c9be921fb8b65ac094a408 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;
        }
@@ -18,7 +18,7 @@ int gitsetenv(const char *name, const char *value, int replace)
 
        namelen = strlen(name);
        valuelen = strlen(value);
-       envstr = malloc((namelen + valuelen + 2));
+       envstr = malloc(st_add3(namelen, valuelen, 2));
        if (!envstr) {
                errno = ENOMEM;
                return -1;