summaryrefslogtreecommitdiff
path: root/usr.bin/nohup
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-28 00:50:14 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-28 00:50:14 +0000
commit7045d1de0f5ad76806333a19de48f00256ebd939 (patch)
treebcc283c26438cc43c85d973599eaf1657788fd88 /usr.bin/nohup
parenta02bc38ce45e99943afe9f23eb22a1b051e7a27c (diff)
Safe $HOME handling.
Diffstat (limited to 'usr.bin/nohup')
-rw-r--r--usr.bin/nohup/nohup.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/nohup/nohup.c b/usr.bin/nohup/nohup.c
index 73f5ed29453..369b64ce530 100644
--- a/usr.bin/nohup/nohup.c
+++ b/usr.bin/nohup/nohup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nohup.c,v 1.2 1996/06/26 05:37:36 deraadt Exp $ */
+/* $OpenBSD: nohup.c,v 1.3 1996/10/28 00:50:13 millert Exp $ */
/* $NetBSD: nohup.c,v 1.6 1995/08/31 23:35:25 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)nohup.c 5.4 (Berkeley) 6/1/90";
#endif
-static char rcsid[] = "$OpenBSD: nohup.c,v 1.2 1996/06/26 05:37:36 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: nohup.c,v 1.3 1996/10/28 00:50:13 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -116,7 +116,8 @@ dofile()
p = FILENAME;
if ((fd = open(p, O_RDWR|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR)) >= 0)
goto dupit;
- if ((p = getenv("HOME")) != NULL) {
+ if ((p = getenv("HOME")) != NULL &&
+ (strlen(p) + strlen(FILENAME) + 1) < sizeof(path)) {
(void)strcpy(path, p);
(void)strcat(path, "/");
(void)strcat(path, FILENAME);