summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/putenv.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2007-04-30 02:25:02 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2007-04-30 02:25:02 +0000
commitbdda89347122e9814a3a681adfc4d950fa914066 (patch)
treef3c51d97304bef50f993149ee17487bb6c86505e /lib/libc/stdlib/putenv.c
parent2f51d936261e9ecf8fab77b6baf730ccd55942e3 (diff)
Notes
Diffstat (limited to 'lib/libc/stdlib/putenv.c')
-rw-r--r--lib/libc/stdlib/putenv.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libc/stdlib/putenv.c b/lib/libc/stdlib/putenv.c
index a5eea5d0ddfdd..b6c7ccb67f837 100644
--- a/lib/libc/stdlib/putenv.c
+++ b/lib/libc/stdlib/putenv.c
@@ -33,24 +33,28 @@ static char sccsid[] = "@(#)putenv.c 8.2 (Berkeley) 3/27/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
int
putenv(str)
- const char *str;
+ char *str;
{
char *p, *equal;
- int rval;
+ int rval, serrno;
if ((p = strdup(str)) == NULL)
return (-1);
if ((equal = index(p, '=')) == NULL) {
(void)free(p);
+ errno = EINVAL;
return (-1);
}
*equal = '\0';
rval = setenv(p, equal + 1, 1);
+ serrno = errno;
(void)free(p);
+ errno = serrno;
return (rval);
}