From bc843bdaea2c5cdfa13abd41ea3ea01f533ee149 Mon Sep 17 00:00:00 2001 From: naddy <> Date: Tue, 29 Jun 2010 04:09:34 +0000 Subject: Make unsetenv(NULL) and unsetenv("") give EINVAL, per POSIX. ok deraadt@ --- src/lib/libc/stdlib/setenv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/lib') diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c index 2e882cdbe6..89d1e88911 100644 --- a/src/lib/libc/stdlib/setenv.c +++ b/src/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) { -- cgit v1.2.3-55-g6feb