summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1998-07-26 17:06:05 +0000
committerimp <imp@FreeBSD.org>1998-07-26 17:06:05 +0000
commit3f6e3c331abdab065198b0bd8895cbc9ee8bb132 (patch)
tree2c2a9944efa39e019f0c5dd0479cfdc588921f2b
parent685645c4eb2aab46cd70202b9f4f7c6899bb5dc0 (diff)
downloadFreeBSD-src-3f6e3c331abdab065198b0bd8895cbc9ee8bb132.zip
FreeBSD-src-3f6e3c331abdab065198b0bd8895cbc9ee8bb132.tar.gz
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).
-rw-r--r--usr.bin/make/main.c6
1 files changed, 4 insertions, 2 deletions
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);
OpenPOWER on IntegriCloud