aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/setenv.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c
index b8d234929f..6f871a65c7 100644
--- a/sysdeps/generic/setenv.c
+++ b/sysdeps/generic/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1992,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -263,13 +263,21 @@ setenv (name, value, replace)
return __add_to_environ (name, value, NULL, replace);
}
-void
+int
unsetenv (name)
const char *name;
{
- const size_t len = strlen (name);
+ const size_t len;
char **ep;
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ len = strlen (name);
+
LOCK;
ep = __environ;
@@ -288,6 +296,8 @@ unsetenv (name)
++ep;
UNLOCK;
+
+ return 0;
}
/* The `clearenv' was planned to be added to POSIX.1 but probably