diff options
author | 2012-09-23 16:08:04 +0000 | |
---|---|---|
committer | 2012-09-23 16:08:04 +0000 | |
commit | 98da8fe0e7d3de45f88b48bb2d0c819bd789b300 (patch) | |
tree | db5389e92fefbdeef156989770b48b7655ad5d2c /lib/libc/stdlib/setenv.c | |
parent | uint32_t is the integer type defined in stdint.h (diff) | |
download | wireguard-openbsd-98da8fe0e7d3de45f88b48bb2d0c819bd789b300.tar.xz wireguard-openbsd-98da8fe0e7d3de45f88b48bb2d0c819bd789b300.zip |
Make setenv(3) consistent with unsetenv(3), giving EINVAL if passed
an empty name, NULL pointer, or a name containing an '=' character.
OK millert@, guenther@
Diffstat (limited to 'lib/libc/stdlib/setenv.c')
-rw-r--r-- | lib/libc/stdlib/setenv.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c index 089ab92d38f..9060fdba880 100644 --- a/lib/libc/stdlib/setenv.c +++ b/lib/libc/stdlib/setenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setenv.c,v 1.13 2010/08/23 22:31:50 millert Exp $ */ +/* $OpenBSD: setenv.c,v 1.14 2012/09/23 16:08:04 jeremy Exp $ */ /* * Copyright (c) 1987 Regents of the University of California. * All rights reserved. @@ -94,14 +94,16 @@ setenv(const char *name, const char *value, int rewrite) const char *np; int l_value, offset = 0; + if (!name || !*name) { + errno = EINVAL; + return (-1); + } for (np = name; *np && *np != '='; ++np) ; -#ifdef notyet if (*np) { errno = EINVAL; return (-1); /* has `=' in name */ } -#endif l_value = strlen(value); if ((C = __findenv(name, (int)(np - name), &offset)) != NULL) { |