diff options
author | Roland McGrath <roland@gnu.org> | 2002-09-11 22:04:32 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-09-11 22:04:32 +0000 |
commit | 0d35c2426d7a2682631da0433299e1c912f0ccfa (patch) | |
tree | 08e37bfeb9f28315573e2d3127f4c0cefafebd95 /sysdeps/generic | |
parent | 2c333cf190aeb3b3d71acf73b6b060c1662dbf71 (diff) | |
download | glibc-0d35c2426d7a2682631da0433299e1c912f0ccfa.tar.gz glibc-0d35c2426d7a2682631da0433299e1c912f0ccfa.tar.xz glibc-0d35c2426d7a2682631da0433299e1c912f0ccfa.zip |
* sysdeps/generic/dl-environ.c (unsetenv): Rewritten using strncmp,
no longer wrongly matches arbitrary prefixes of NAME. Reported by Jakub Jelinek <jakub@redhat.com>. 2002-09-11 Jakub Jelinek <jakub@redhat.com> * posix/bug-regex11.c (tests): New array. (main): Rewritten to run more different tests. * nscd/Makefile (CPPFLAGS-nscd, CPPFLAGS-nscd_conf, CPPFLAGS-dbg_log) (CPPFLAGS-connections, CPPFLAGS-hstcache): Variables removed. Instead, catch all of $(nscd-modules) via cppflags-iterator.mk.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/dl-environ.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/sysdeps/generic/dl-environ.c b/sysdeps/generic/dl-environ.c index 132dad9c3e..30fe5654d6 100644 --- a/sysdeps/generic/dl-environ.c +++ b/sysdeps/generic/dl-environ.c @@ -57,30 +57,23 @@ extern char **__environ attribute_hidden; int unsetenv (const char *name) { + const size_t len = strlen (name); char **ep; ep = __environ; while (*ep != NULL) - { - size_t cnt = 0; - - while ((*ep)[cnt] == name[cnt] && name[cnt] != '\0') - ++cnt; - - if ((*ep)[cnt] == '=') - { - /* Found it. Remove this pointer by moving later ones to - the front. */ - char **dp = ep; - - do - dp[0] = dp[1]; - while (*dp++); - /* Continue the loop in case NAME appears again. */ - } - else - ++ep; - } + if (!strncmp (*ep, name, len) && (*ep)[len] == '=') + { + /* Found it. Remove this pointer by moving later ones back. */ + char **dp = ep; + + do + dp[0] = dp[1]; + while (*dp++); + /* Continue the loop in case NAME appears again. */ + } + else + ++ep; return 0; } |