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(1): improve local variable name in ParseTr...
details: https://anonhg.NetBSD.org/src/rev/eb6ead4e22fc
branches: trunk
changeset: 956521:eb6ead4e22fc
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Oct 31 23:10:06 2020 +0000
description:
make(1): improve local variable name in ParseTrackInput
By the way, the Address Sanitizer that ran over this code on 2015-11-26
didn't find the other out-of-bounds bug. Most probably the Address
Sanitizer only detected obvious bugs in the actual test data, and there
was no test case in which .MAKE.MAKEFILES was shorter than the newly
added makefile.
diffstat:
usr.bin/make/parse.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diffs (44 lines):
diff -r 14e1ee346672 -r eb6ead4e22fc usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sat Oct 31 23:01:23 2020 +0000
+++ b/usr.bin/make/parse.c Sat Oct 31 23:10:06 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $");
/* types and constants */
@@ -2356,11 +2356,12 @@
static void
ParseTrackInput(const char *name)
{
- void *fp = NULL;
-
- const char *old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
- if (old) {
+ void *old_freeIt = NULL;
+
+ const char *old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &old_freeIt);
+ if (old != NULL) {
size_t name_len = strlen(name);
+ /* XXX: undefined behavior if name_len > strlen(old) */
const char *ep = old + strlen(old) - name_len;
/* does it contain name? */
for (; old != NULL; old = strchr(old, ' ')) {
@@ -2375,7 +2376,7 @@
}
Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
cleanup:
- bmake_free(fp);
+ bmake_free(old_freeIt);
}
Home |
Main Index |
Thread Index |
Old Index