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: fix out-of-bounds memory read (since prev...



details:   https://anonhg.NetBSD.org/src/rev/8d1644597382
branches:  trunk
changeset: 1023678:8d1644597382
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Sep 21 21:03:36 2021 +0000

description:
make: fix out-of-bounds memory read (since previous commit)

diffstat:

 usr.bin/make/cond.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r fd021ddeea18 -r 8d1644597382 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Tue Sep 21 20:54:42 2021 +0000
+++ b/usr.bin/make/cond.c       Tue Sep 21 21:03:36 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -794,10 +794,10 @@
        char *arg = NULL;
        size_t arglen;
        const char *cp = par->p;
-       const struct fn_def *fns_end = fns + sizeof fns / sizeof fns[0];
+       const struct fn_def *last_fn = fns + sizeof fns / sizeof fns[0] - 1;
 
        for (fn = fns; !is_token(cp, fn->fn_name, fn->fn_name_len); fn++)
-               if (fn == fns_end)
+               if (fn == last_fn)
                        return false;
 
        cp += fn->fn_name_len;



Home | Main Index | Thread Index | Old Index