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: fix out-of-bounds read in Var_Parse_FastL...



details:   https://anonhg.NetBSD.org/src/rev/ee9f9b64d7c1
branches:  trunk
changeset: 961112:ee9f9b64d7c1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 10 22:40:34 2021 +0000

description:
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.

diffstat:

 usr.bin/make/var.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r f820e75e1780 -r ee9f9b64d7c1 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Apr 10 22:35:02 2021 +0000
+++ b/usr.bin/make/var.c        Sat Apr 10 22:40:34 2021 +0000
@@ -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 @@
                return false;
 
        p += 4;
-       while (*p != '$' && *p != '{' && *p != ':' && *p != '\\' && *p != '}')
+       while (*p != '$' && *p != '{' && *p != ':' && *p != '\\' &&
+              *p != '}' && *p != '\0')
                p++;
        if (*p != '}')
                return false;



Home | Main Index | Thread Index | Old Index