ParseTrackInput: do not access beyond end of buffer.

Reviewed by:	dim
This commit is contained in:
sjg 2015-11-26 00:26:23 +00:00
parent 00cd225d95
commit 175e2b18f6

View File

@ -2390,15 +2390,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;