Module Name: src Committed By: rillig Date: Tue Sep 21 21:03:36 UTC 2021
Modified Files: src/usr.bin/make: cond.c Log Message: make: fix out-of-bounds memory read (since previous commit) To generate a diff of this commit: cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/cond.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/cond.c diff -u src/usr.bin/make/cond.c:1.272 src/usr.bin/make/cond.c:1.273 --- src/usr.bin/make/cond.c:1.272 Tue Sep 21 20:54:42 2021 +++ src/usr.bin/make/cond.c Tue Sep 21 21:03:36 2021 @@ -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 @@ CondParser_FuncCall(CondParser *par, boo 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;