diff options
author | 2004-03-05 22:02:18 +0000 | |
---|---|---|
committer | 2004-03-05 22:02:18 +0000 | |
commit | 3a875383af5d50ba7395a065e473938bc05c60d5 (patch) | |
tree | 8de8ff1dcf0f9b70c82ab5f2f723f40ad20dc762 | |
parent | plug a couple of memory leaks, Patrick Latifi (diff) | |
download | wireguard-openbsd-3a875383af5d50ba7395a065e473938bc05c60d5.tar.xz wireguard-openbsd-3a875383af5d50ba7395a065e473938bc05c60d5.zip |
don't panic if we can't getcwd() initially, just chdir("/")
spotted by and ok henning
-rw-r--r-- | usr.bin/mg/dir.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/mg/dir.c b/usr.bin/mg/dir.c index d9b9721a914..27e9b39da5d 100644 --- a/usr.bin/mg/dir.c +++ b/usr.bin/mg/dir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.c,v 1.9 2002/07/01 14:33:44 vincent Exp $ */ +/* $OpenBSD: dir.c,v 1.10 2004/03/05 22:02:18 vincent Exp $ */ /* * Name: MG 2a @@ -19,8 +19,11 @@ static char cwd[NFILEN]; void dirinit(void) { - if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL) - panic("Can't get current directory!"); + if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL) { + ewprintf("Can't get current directory!"); + chdir("/"); + strlcpy(cwd, "/", sizeof(cwd)); + } } /* |