summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-12-31 01:08:59 +0000
committerrillig <rillig@NetBSD.org>2021-12-31 01:08:59 +0000
commit01a49874dee62d0625596e67afb6469dc9309945 (patch)
tree5195e26539ed88c845ea89d33eadfdfd38f7e00e /usr.bin/make/parse.c
parentab7efa96628ab3bb171c3a3040e0a5599fcbe46d (diff)
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.
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 76dc7cba1fb..3ad679c33e4 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -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, const char *nameEnd, const char *op,
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;
}