From 3f6e3c331abdab065198b0bd8895cbc9ee8bb132 Mon Sep 17 00:00:00 2001 From: imp Date: Sun, 26 Jul 1998 17:06:05 +0000 Subject: Use malloc + sprintf rather than asprintf to ensure portability to other, less advanced architecutres. This should minorly help porting efforts of FreeBSD. I've done several make worlds since this came up with this change, as well as debugging several interesting nits with -V (which is the only thing this change will affect really). --- usr.bin/make/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index efcfcfd..8f82d1d 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -47,7 +47,7 @@ static const char copyright[] = static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #endif static const char rcsid[] = - "$Id: main.c,v 1.23 1997/09/29 03:53:51 imp Exp $"; + "$Id: main.c,v 1.24 1998/06/13 11:55:57 peter Exp $"; #endif /* not lint */ /*- @@ -186,9 +186,11 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { break; case 'V': printVars = TRUE; - (void)asprintf(&p, "${%s}", optarg); + p = malloc(strlen(optarg) + 1 + 3); if (!p) Punt("make: cannot allocate memory."); + /* This sprintf is safe, because of the malloc above */ + (void)sprintf(p, "${%s}", optarg); (void)Lst_AtEnd(variables, (ClientData)p); Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); -- cgit v1.1