Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): prefer memcmp over strncmp



details:   https://anonhg.NetBSD.org/src/rev/8209cfd612d0
branches:  trunk
changeset: 936173:8209cfd612d0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jul 20 15:48:50 2020 +0000

description:
make(1): prefer memcmp over strncmp

diffstat:

 usr.bin/make/var.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 4f26beaac42c -r 8209cfd612d0 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Jul 20 15:44:12 2020 +0000
+++ b/usr.bin/make/var.c        Mon Jul 20 15:48:50 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.281 2020/07/20 15:44:12 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.282 2020/07/20 15:48:50 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.281 2020/07/20 15:44:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.282 2020/07/20 15:48:50 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.281 2020/07/20 15:44:12 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.282 2020/07/20 15:48:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1359,7 +1359,8 @@
        goto nosub;
 
     if (args->pflags & VARP_MATCH_START) {
-       if (strncmp(word, args->lhs, args->lhsLen) != 0)
+       if (wordLen < args->lhsLen ||
+           memcmp(word, args->lhs, args->lhsLen) != 0)
            goto nosub;
 
        if (args->pflags & VARP_MATCH_END) {



Home | Main Index | Thread Index | Old Index