Module Name: src
Committed By: sjg
Date: Thu Nov 26 00:23:04 UTC 2015
Modified Files:
src/usr.bin/make: parse.c
Log Message:
ParseTrackInput: do not access beyond end of buffer.
Detected by Address Sanitizer - dim at FreeBSD.org
To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 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.205 src/usr.bin/make/parse.c:1.206
--- src/usr.bin/make/parse.c:1.205 Sun Oct 11 04:51:24 2015
+++ src/usr.bin/make/parse.c Thu Nov 26 00:23:04 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.205 2015/10/11 04:51:24 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.206 2015/11/26 00:23:04 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2380,15 +2380,19 @@ static void
ParseTrackInput(const char *name)
{
char *old;
+ char *ep;
char *fp = NULL;
size_t name_len = strlen(name);
old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp);
if (old) {
+ ep = old + strlen(old) - name_len;
/* does it contain name? */
for (; old != NULL; old = strchr(old, ' ')) {
if (*old == ' ')
old++;
+ if (old >= ep)
+ break; /* cannot contain name */
if (memcmp(old, name, name_len) == 0
&& (old[name_len] == 0 || old[name_len] == ' '))
goto cleanup;