Quellcode durchsuchen

fix for setenv bogus var argument handling

thanks to mikachu

per POSIX:

The setenv() function shall fail if:

[EINVAL] The name argument is a null pointer, points to an empty
string, or points to a string containing an '=' character.
Rich Felker vor 13 Jahren
Ursprung
Commit
649af9f73a
1 geänderte Dateien mit 1 neuen und 1 gelöschten Zeilen
  1. 1 1
      src/env/setenv.c

+ 1 - 1
src/env/setenv.c

@@ -9,7 +9,7 @@ int setenv(const char *var, const char *value, int overwrite)
 	char *s;
 	int l1, l2;
 
-	if (strchr(var, '=')) {
+	if (!var || !*var || strchr(var, '=')) {
 		errno = EINVAL;
 		return -1;
 	}