Module Name:    src
Committed By:   rillig
Date:           Sat Apr 10 22:40:34 UTC 2021

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

Log Message:
make: fix out-of-bounds read in Var_Parse_FastLane (since 30 minutes)

This bug made the test varmod-edge.mk fail sometimes with varying error
messages, as can be expected for an out-of-bounds read.


To generate a diff of this commit:
cvs rdiff -u -r1.914 -r1.915 src/usr.bin/make/var.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/var.c
diff -u src/usr.bin/make/var.c:1.914 src/usr.bin/make/var.c:1.915
--- src/usr.bin/make/var.c:1.914	Sat Apr 10 22:35:02 2021
+++ src/usr.bin/make/var.c	Sat Apr 10 22:40:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.914 2021/04/10 22:35:02 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.915 2021/04/10 22:40:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.914 2021/04/10 22:35:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.915 2021/04/10 22:40:34 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4401,7 +4401,8 @@ Var_Parse_FastLane(const char **pp, VarE
 		return false;
 
 	p += 4;
-	while (*p != '$' && *p != '{' && *p != ':' && *p != '\\' && *p != '}')
+	while (*p != '$' && *p != '{' && *p != ':' && *p != '\\' &&
+	       *p != '}' && *p != '\0')
 		p++;
 	if (*p != '}')
 		return false;

Reply via email to