Subject: Re: CVS commit: src/usr.bin/make
To: None <source-changes@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: source-changes
Date: 10/13/2007 14:27:25
On Fri, 12 Oct 2007, David Laight wrote:
> Modified Files:
> 	src/usr.bin/make: job.c
> 
> Log Message:
> Var_Subst() seems to write into its input string! So we do need a copy.

In this particular case, Var_Subst (at line 3668) calls Var_Parse, which
blows up at line 3330.

var.c is littered with uses of the WR() macro to write into const
strings.  This usually seems to be for the purpose of temporarily
changing a delimiter character to \0', and restoring the original
character later.

It looks easy enough to change the code to use strdup()/free() to make
the changes to a temporary copy of the string.  It should also be
possible to avoid either copying the string or writing to the string,
by using extra counters or pointers to keep track of the substrings of
interest.

--apb (Alan Barrett)