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 off-by-one error in buffer for .WAIT ...



details:   https://anonhg.NetBSD.org/src/rev/807f0bf4984b
branches:  trunk
changeset: 365990:807f0bf4984b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat May 07 17:25:28 2022 +0000

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

diffstat:

 usr.bin/make/parse.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (33 lines):

diff -r 3bd593ef9635 -r 807f0bf4984b usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat May 07 14:59:25 2022 +0000
+++ b/usr.bin/make/parse.c      Sat May 07 17:25:28 2022 +0000
@@ -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 @@
 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;



Home | Main Index | Thread Index | Old Index