[PATCH] add argument check in setenv()
Xishi Qiu
qiuxishi at huawei.com
Tue Nov 4 11:26:28 UTC 2014
setenv() in glibc/eglibc will check the argument, like this,
...
if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
{
__set_errno (EINVAL);
return -1;
}
...
So add argument check in uclibc's setenv() too.
Signed-off-by: Xishi Qiu <qiuxishi at huawei.com>
---
libc/stdlib/setenv.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/libc/stdlib/setenv.c b/libc/stdlib/setenv.c
index 00e3f3d..0ca6daf 100644
--- a/libc/stdlib/setenv.c
+++ b/libc/stdlib/setenv.c
@@ -116,6 +116,11 @@ static int __add_to_environ(const char *name, const char *value,
int setenv(const char *name, const char *value, int replace)
{
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL) {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
/* NB: setenv("VAR", NULL, 1) inserts "VAR=" string */
return __add_to_environ(name, value ? value : "", replace);
}
--
1.6.0.2
More information about the uClibc
mailing list