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
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2009-11-16 23:05:49 +0300
committerEric Blake <eblake@redhat.com>2009-11-16 23:05:49 +0300
commitd01a44977f7f28ee5f3a2d14b01cf14690a5852e (patch)
tree4179a34665f3eaa51c0cc416f2cf540a58c5a137 /winsup/cygwin/environ.cc
parent5074489a49be6c20689bd3b7b4b4d8c6ace28435 (diff)
Fix setenv and unsetenv corner cases.
* environ.cc (setenv): Detect invalid argument. (unsetenv): Distinguish EFAULT from EINVAL.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r--winsup/cygwin/environ.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index bc1130372..4935bc815 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -413,10 +413,11 @@ setenv (const char *name, const char *value, int overwrite)
myfault efault;
if (efault.faulted (EFAULT))
return -1;
- if (!*name)
- return 0;
- if (*value == '=')
- value++;
+ if (!name || !*name || strchr (name, '='))
+ {
+ set_errno (EINVAL);
+ return -1;
+ }
return _addenv (name, value, !!overwrite);
}
@@ -427,7 +428,9 @@ unsetenv (const char *name)
register char **e;
int offset;
myfault efault;
- if (efault.faulted () || *name == '\0' || strchr (name, '='))
+ if (efault.faulted (EFAULT))
+ return -1;
+ if (!name || *name == '\0' || strchr (name, '='))
{
set_errno (EINVAL);
return -1;