summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorJeremy Evans <jeremy@cvs.openbsd.org>2012-09-23 16:08:05 +0000
committerJeremy Evans <jeremy@cvs.openbsd.org>2012-09-23 16:08:05 +0000
commit75f4140c066d471968b62f697ba7a6b4a9502719 (patch)
treeb37b9920c853c72a2561522a983e3f24203ea039 /lib/libc/stdlib
parent103aa57fddf69424b12defe84d9f0d063c1283fa (diff)
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')
-rw-r--r--lib/libc/stdlib/getenv.322
-rw-r--r--lib/libc/stdlib/setenv.c8
2 files changed, 10 insertions, 20 deletions
diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3
index 8c2b633f257..f987eb13a1c 100644
--- a/lib/libc/stdlib/getenv.3
+++ b/lib/libc/stdlib/getenv.3
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: getenv.3,v 1.17 2012/06/02 00:14:16 guenther Exp $
+.\" $OpenBSD: getenv.3,v 1.18 2012/09/23 16:08:04 jeremy Exp $
.\"
-.Dd $Mdocdate: June 2 2012 $
+.Dd $Mdocdate: September 23 2012 $
.Dt GETENV 3
.Os
.Sh NAME
@@ -53,14 +53,6 @@
.Sh DESCRIPTION
These functions set, unset, and fetch environment variables from the host
.Em environment list .
-For compatibility with differing environment conventions, the given argument
-.Fa name
-may be appended with an equal sign
-.Dq Li \&=
-followed by zero or more characters,
-and
-.Fa value
-may be prepended with an equal sign.
.Pp
The
.Fn getenv
@@ -125,19 +117,15 @@ The
.Fn setenv
or
.Fn unsetenv
-function was passed a
+function was passed an empty
+.Ar name
+or a NULL pointer, or was passed a
.Ar name
containing an
.Sq =
character.
.Pp
The
-.Fn unsetenv
-function was passed an empty
-.Ar name
-or a NULL pointer.
-.Pp
-The
.Fn putenv
function was passed a
.Ar string
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) {