summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorkleink <kleink@NetBSD.org>1999-07-21 15:20:55 +0000
committerkleink <kleink@NetBSD.org>1999-07-21 15:20:55 +0000
commitfbfc6d0d2820a173443cbf64a9df1b0550e192d3 (patch)
treedfdd5b30548b21efe273475822353286b1947a28 /usr.bin
parentf484530816f8b1e4a81533b9392949dabe9b7763 (diff)
Rather than hardcoding _PATH_TMP (and relying on const string concatenation),
try TMPDIR (if set in the environment).
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mkdep/mkdep.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/mkdep/mkdep.c b/usr.bin/mkdep/mkdep.c
index b5c22e1d379..565e139b686 100644
--- a/usr.bin/mkdep/mkdep.c
+++ b/usr.bin/mkdep/mkdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mkdep.c,v 1.3 1999/03/31 11:26:45 kleink Exp $ */
+/* $NetBSD: mkdep.c,v 1.4 1999/07/21 15:20:55 kleink Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\n\
#endif /* not lint */
#ifndef lint
-__RCSID("$NetBSD: mkdep.c,v 1.3 1999/03/31 11:26:45 kleink Exp $");
+__RCSID("$NetBSD: mkdep.c,v 1.4 1999/07/21 15:20:55 kleink Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -120,6 +120,7 @@ main(argc, argv)
int aflag, pflag, index, tmpfd, status;
pid_t cpid, pid;
char *filename, *CC, *pathname, tmpfilename[MAXPATHLEN], **args;
+ const char *tmpdir;
/* LINTED local definition of tmpfile */
FILE *tmpfile, *dependfile;
char buffer[32768];
@@ -166,7 +167,10 @@ main(argc, argv)
args[1] = "-M";
(void)memcpy(&args[2], argv, (argc + 1) * sizeof(char *));
- (void)strcpy(tmpfilename, _PATH_TMP "mkdepXXXXXX");
+ if ((tmpdir = getenv("TMPDIR")) == NULL)
+ tmpdir = _PATH_TMP;
+ (void)snprintf(tmpfilename, sizeof (tmpfilename), "%s/%s", tmpdir,
+ "mkdepXXXXXX");
if ((tmpfd = mkstemp (tmpfilename)) < 0) {
warn("unable to create temporary file %s", tmpfilename);
return EXIT_FAILURE;