diff options
author | Robert Mustacchi <rm@joyent.com> | 2016-06-05 12:15:27 -0700 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2016-08-03 09:30:20 -0700 |
commit | 60b81b86c4b2eb3a0481176c344f4b6e7a6276fa (patch) | |
tree | e1d08b8eff9ae11e6ca81b70c21bd34f59aaff38 /usr/src/lib/libc | |
parent | 6bd8a07093bddc0edfc07bfda4ca600e31c02c03 (diff) | |
download | illumos-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.c | 11 |
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)); } |