Module Name:    src
Committed By:   rillig
Date:           Sat May  7 17:25:28 UTC 2022

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

Log Message:
make: fix off-by-one error in buffer for .WAIT nodes

Strangely, GCC didn't warn about this error.  For the buffer overflow to
actually happen, there would have to be a billion .WAIT nodes.


To generate a diff of this commit:
cvs rdiff -u -r1.670 -r1.671 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.670 src/usr.bin/make/parse.c:1.671
--- src/usr.bin/make/parse.c:1.670	Mon Apr 18 16:09:05 2022
+++ src/usr.bin/make/parse.c	Sat May  7 17:25:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.670 2022/04/18 16:09:05 sjg Exp $	*/
+/*	$NetBSD: parse.c,v 1.671 2022/05/07 17:25:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.670 2022/04/18 16:09:05 sjg Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.671 2022/05/07 17:25:28 rillig Exp $");
 
 /*
  * A file being read.
@@ -699,11 +699,11 @@ static void
 ApplyDependencySourceWait(bool isSpecial)
 {
 	static unsigned wait_number = 0;
-	char wait_src[16];
+	char name[6 + 10 + 1];
 	GNode *gn;
 
-	snprintf(wait_src, sizeof wait_src, ".WAIT_%u", ++wait_number);
-	gn = Targ_NewInternalNode(wait_src);
+	snprintf(name, sizeof name, ".WAIT_%u", ++wait_number);
+	gn = Targ_NewInternalNode(name);
 	if (doing_depend)
 		RememberLocation(gn);
 	gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;

Reply via email to