Index: libc/stdlib/getenv_r.c =================================================================== RCS file: /cvs/src/src/newlib/libc/stdlib/getenv_r.c,v retrieving revision 1.6 diff -u -p -r1.6 getenv_r.c --- libc/stdlib/getenv_r.c 25 Sep 2008 01:23:08 -0000 1.6 +++ libc/stdlib/getenv_r.c 25 Sep 2008 15:44:06 -0000 @@ -29,7 +29,8 @@ A pointer to the (string) value of the e 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 <>. */ @@ -98,17 +99,22 @@ _DEFUN (_findenv_r, (reent_ptr, name, of 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; } Index: ChangeLog =================================================================== RCS file: /cvs/src/src/newlib/ChangeLog,v retrieving revision 1.1195 diff -u -p -r1.1195 ChangeLog --- ChangeLog 25 Sep 2008 03:00:03 -0000 1.1195 +++ ChangeLog 25 Sep 2008 15:44:10 -0000 @@ -1,3 +1,8 @@ +2008-09-25 Craig Howland + + * libc/stdlib/getenv_r.c (_getenv_r): Modify to not match if name + contains an equal sign. + 2008-09-24 Jeff Johnston * libc/stdlib/setenv_r.c (_unsetenv_r): Modify to return -1 only if