Module Name:    src
Committed By:   sjg
Date:           Mon Jun  4 22:45:06 UTC 2012

Modified Files:
        src/usr.bin/make: util.c

Log Message:
Fix findenv() to fully match name


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/make/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/util.c
diff -u src/usr.bin/make/util.c:1.52 src/usr.bin/make/util.c:1.53
--- src/usr.bin/make/util.c:1.52	Mon Jun  4 20:34:20 2012
+++ src/usr.bin/make/util.c	Mon Jun  4 22:45:05 2012
@@ -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 @@ findenv(const char *name, int *offset)
 	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;
 		}

Reply via email to