Module Name:    src
Committed By:   rillig
Date:           Fri Dec 31 01:08:59 UTC 2021

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

Log Message:
make: prevent out-of-bounds pointer in AdjustVarassignOp

It's a rather theoretical case that 'name' would point at the very end
of the address space and the string there would be "V=", but in that
case, the expression 'name + 3' would wrap around.


To generate a diff of this commit:
cvs rdiff -u -r1.607 -r1.608 src/usr.bin/make/parse.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/parse.c
diff -u src/usr.bin/make/parse.c:1.607 src/usr.bin/make/parse.c:1.608
--- src/usr.bin/make/parse.c:1.607	Fri Dec 31 00:45:21 2021
+++ src/usr.bin/make/parse.c	Fri Dec 31 01:08:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.607 2021/12/31 00:45:21 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.608 2021/12/31 01:08:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.607 2021/12/31 00:45:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.608 2021/12/31 01:08:59 rillig Exp $");
 
 /* types and constants */
 
@@ -1672,7 +1672,7 @@ AdjustVarassignOp(const char *name, cons
 		while (op > name && ch_isspace(op[-1]))
 			op--;
 
-		if (op >= name + 3 && memcmp(op - 3, ":sh", 3) == 0) {
+		if (op - name >= 3 && memcmp(op - 3, ":sh", 3) == 0) {
 			op -= 3;
 			type = VAR_SHELL;
 		}

Reply via email to