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): fix undefined behavior in Parse_IsVar
details: https://anonhg.NetBSD.org/src/rev/e6f0395361ef
branches: trunk
changeset: 941994:e6f0395361ef
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Nov 02 22:50:55 2020 +0000
description:
make(1): fix undefined behavior in Parse_IsVar
Even though the pointer was out-of-bounds, a crash was unlikely in
practice, since typical C compilers don't check the pointers for invalid
values after each modification. The memory it pointed to was not
accessed though.
diffstat:
usr.bin/make/parse.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diffs (38 lines):
diff -r 3781cc6fa81d -r e6f0395361ef usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Mon Nov 02 22:46:52 2020 +0000
+++ b/usr.bin/make/parse.c Mon Nov 02 22:50:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.421 2020/11/02 22:44:29 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.422 2020/11/02 22:50:55 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.421 2020/11/02 22:44:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.422 2020/11/02 22:50:55 rillig Exp $");
/* types and constants */
@@ -1832,7 +1832,6 @@
{
VarAssignParsed pvar;
const char *firstSpace = NULL;
- char ch;
int level = 0;
/* Skip to variable name */
@@ -1850,9 +1849,8 @@
#endif
/* Scan for one of the assignment operators outside a variable expansion */
- /* FIXME: undefined behavior. In unit-tests/varname.mk:try1, at the end
- * of the loop, p already points to the next line. */
- while ((ch = *p++) != 0) {
+ while (*p != '\0') {
+ char ch = *p++;
if (ch == '(' || ch == '{') {
level++;
continue;
Home |
Main Index |
Thread Index |
Old Index