summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2016-06-05 12:15:27 -0700
committerRobert Mustacchi <rm@joyent.com>2016-08-03 09:30:20 -0700
commit60b81b86c4b2eb3a0481176c344f4b6e7a6276fa (patch)
treee1d08b8eff9ae11e6ca81b70c21bd34f59aaff38 /usr/src/lib/libc
parent6bd8a07093bddc0edfc07bfda4ca600e31c02c03 (diff)
downloadillumos-joyent-60b81b86c4b2eb3a0481176c344f4b6e7a6276fa.tar.gz
7076 segfault in putenv + getenv
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Dave Eddy <dave.eddy@joyent.com> Reviewed by: Cody Mello <melloc@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Gordon Ross <gordon.ross@nexenta.com> Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Approved by: Dan McDonald <danmcd@omniti.com>
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/port/gen/getenv.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/usr/src/lib/libc/port/gen/getenv.c b/usr/src/lib/libc/port/gen/getenv.c
index c345226d0c..bd13a749ed 100644
--- a/usr/src/lib/libc/port/gen/getenv.c
+++ b/usr/src/lib/libc/port/gen/getenv.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
/* Copyright (c) 1988 AT&T */
@@ -336,6 +337,16 @@ addtoenv(char *string, int overwrite)
int
putenv(char *string)
{
+ /*
+ * Historically a call to putenv() with no '=' in the string would work
+ * great until someone called getenv() on that particular environment
+ * variable again. As we've always treated this as valid, rather than
+ * teaching the rest of the environment code how to handle something
+ * without an '=' sign, it instead just calls unsetenv().
+ */
+ if (strchr(string, '=') == NULL)
+ return (unsetenv(string));
+
return (addtoenv(string, 1));
}