Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2008-09-25 07:00:04 +0400
committerJeff Johnston <jjohnstn@redhat.com>2008-09-25 07:00:04 +0400
commit57d7cfcdb7b9cc94fa2de90a9b87eeff40f39bca (patch)
tree26872af54de1d171fd1fc33396becc71bd67d637 /newlib
parent37f996a2b22baba8cc6ee7df87f72df25de36737 (diff)
2008-09-24 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/setenv_r.c (_unsetenv_r): Modify to return -1 only if name is NULL, empty, or contains equal sign.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/stdlib/setenv_r.c11
2 files changed, 9 insertions, 7 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 4d2fa61e5..0dee816a5 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-24 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/stdlib/setenv_r.c (_unsetenv_r): Modify to return -1 only if
+ name is NULL, empty, or contains equal sign.
+
2008-09-24 Pawel Veselov <pawel.veselov@gmail.com>
Fix setenv/getenv/unsetenv to be OpenGroup compliant:
diff --git a/newlib/libc/stdlib/setenv_r.c b/newlib/libc/stdlib/setenv_r.c
index e9ae76ef5..d73ba3949 100644
--- a/newlib/libc/stdlib/setenv_r.c
+++ b/newlib/libc/stdlib/setenv_r.c
@@ -146,9 +146,9 @@ _DEFUN (_unsetenv_r, (reent_ptr, name),
{
register char **P;
int offset;
- int rc;
-
- if (strchr(name, '='))
+
+ /* Name cannot be NULL, empty, or contain an equal sign. */
+ if (name == NULL || name[0] == '\0' || strchr(name, '='))
{
errno = EINVAL;
return -1;
@@ -156,16 +156,13 @@ _DEFUN (_unsetenv_r, (reent_ptr, name),
ENV_LOCK;
- rc = -1;
-
while (_findenv_r (reent_ptr, name, &offset)) /* if set multiple times */
{
- rc = 0;
for (P = &(*p_environ)[offset];; ++P)
if (!(*P = *(P + 1)))
break;
}
ENV_UNLOCK;
- return (rc);
+ return 0;
}