Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Fix findenv() to fully match name



details:   https://anonhg.NetBSD.org/src/rev/57bbbfd26687
branches:  trunk
changeset: 779599:57bbbfd26687
user:      sjg <sjg%NetBSD.org@localhost>
date:      Mon Jun 04 22:45:05 2012 +0000

description:
Fix findenv() to fully match name

diffstat:

 usr.bin/make/util.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r 0eaa686566f7 -r 57bbbfd26687 usr.bin/make/util.c
--- a/usr.bin/make/util.c       Mon Jun 04 22:01:07 2012 +0000
+++ b/usr.bin/make/util.c       Mon Jun 04 22:45:05 2012 +0000
@@ -1,15 +1,15 @@
-/*     $NetBSD: util.c,v 1.52 2012/06/04 20:34:20 sjg Exp $    */
+/*     $NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $    */
 
 /*
  * Missing stuff from OS's
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: util.c,v 1.52 2012/06/04 20:34:20 sjg Exp $";
+static char rcsid[] = "$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: util.c,v 1.52 2012/06/04 20:34:20 sjg Exp $");
+__RCSID("$NetBSD: util.c,v 1.53 2012/06/04 22:45:05 sjg Exp $");
 #endif
 #endif
 
@@ -48,11 +48,12 @@
        size_t i, len;
        char *p, *q;
 
+       len = strlen(name);
        for (i = 0; (q = environ[i]); i++) {
                p = strchr(q, '=');
-               if (p == NULL)
+               if (p == NULL || p - q != len)
                        continue;
-               if (strncmp(name, q, len = p - q) == 0) {
+               if (strncmp(name, q, len) == 0) {
                        *offset = i;
                        return q + len + 1;
                }



Home | Main Index | Thread Index | Old Index