summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/setenv.c
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2010-06-29 04:09:34 +0000
committernaddy <naddy@openbsd.org>2010-06-29 04:09:34 +0000
commitf1fdc1be930d71393f7f4e24ec9c117417cf63a3 (patch)
tree1e448241e9c0bea95fef790ccdf42187835670ef /lib/libc/stdlib/setenv.c
parentmakefstype was only used in ported from freebsd filesystems. fix them (diff)
downloadwireguard-openbsd-f1fdc1be930d71393f7f4e24ec9c117417cf63a3.tar.xz
wireguard-openbsd-f1fdc1be930d71393f7f4e24ec9c117417cf63a3.zip
Make unsetenv(NULL) and unsetenv("") give EINVAL, per POSIX. ok deraadt@
Diffstat (limited to 'lib/libc/stdlib/setenv.c')
-rw-r--r--lib/libc/stdlib/setenv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c
index 2e882cdbe65..89d1e889119 100644
--- a/lib/libc/stdlib/setenv.c
+++ b/lib/libc/stdlib/setenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setenv.c,v 1.11 2009/06/04 20:39:13 millert Exp $ */
+/* $OpenBSD: setenv.c,v 1.12 2010/06/29 04:09:34 naddy Exp $ */
/*
* Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
@@ -145,6 +145,10 @@ unsetenv(const char *name)
const char *np;
int offset;
+ if (!name || !*name) {
+ errno = EINVAL;
+ return (-1);
+ }
for (np = name; *np && *np != '='; ++np)
;
if (*np) {