Message ID | 5458B7E4.9040307@huawei.com |
---|---|
State | Accepted |
Commit | 217f0a86c07beae6a27d422b5f46ee853f3a447a |
Headers | show |
On 4 November 2014 at 12:26, Xishi Qiu <qiuxishi@huawei.com> wrote:
> setenv() in glibc/eglibc will check the argument, like this,
Applied. Thanks!
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); }
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@huawei.com> --- libc/stdlib/setenv.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)