diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2008-09-26 16:23:58 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2008-09-26 16:23:58 +0000 |
commit | 9e71090b9a6ddd3873a581f47423f86b492384c3 (patch) | |
tree | 62ddbb3605ebd121e12e2b4dc292729d4b53236d /newlib | |
parent | 610eefefddbf3537694b9ee43296a576e5e11b72 (diff) | |
download | newlib-9e71090b9a6ddd3873a581f47423f86b492384c3.zip newlib-9e71090b9a6ddd3873a581f47423f86b492384c3.tar.gz newlib-9e71090b9a6ddd3873a581f47423f86b492384c3.tar.bz2 |
2008-09-26 Craig Howland <howland@LGSInnovations.com>
* libc/stdlib/getenv_r.c (_getenv_r): Modify to not match if name
contains an equal sign.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 5 | ||||
-rw-r--r-- | newlib/libc/stdlib/getenv_r.c | 22 |
2 files changed, 19 insertions, 8 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index eb1f88b..61383e9 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2008-09-26 Craig Howland <howland@LGSInnovations.com> + + * libc/stdlib/getenv_r.c (_getenv_r): Modify to not match if name + contains an equal sign. + 2008-09-25 Raphael Derossa Pereira <raphaelpereira@gmail.com> * libc/include/pthread.h[_UNIX98_THREAD_MUTEX_ATTRIBUTES]: Add diff --git a/newlib/libc/stdlib/getenv_r.c b/newlib/libc/stdlib/getenv_r.c index bfa9682..272b097a 100644 --- a/newlib/libc/stdlib/getenv_r.c +++ b/newlib/libc/stdlib/getenv_r.c @@ -29,7 +29,8 @@ A pointer to the (string) value of the environment variable, or PORTABILITY <<_getenv_r>> is not ANSI; the rules for properly forming names of environment -variables vary from one system to another. +variables vary from one system to another. This implementation does not +permit '=' to be in identifiers. <<_getenv_r>> requires a global pointer <<environ>>. */ @@ -98,17 +99,22 @@ _DEFUN (_findenv_r, (reent_ptr, name, offset), return NULL; } - len = strlen(name); - c = name + len; - - for (p = *p_environ; *p; ++p) - if (!strncmp (*p, name, len)) - if (*(c = *p + len) == '=') + c = name; + while (*c && *c != '=') c++; + + /* Identifiers may not contain an '=', so cannot match if does */ + if(*c != '=') + { + len = c - name; + for (p = *p_environ; *p; ++p) + if (!strncmp (*p, name, len)) + if (*(c = *p + len) == '=') { *offset = p - *p_environ; - ENV_UNLOCK; + ENV_UNLOCK; return (char *) (++c); } + } ENV_UNLOCK; return NULL; } |