summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2002-08-08 00:47:34 +0000
committerNiels Provos <provos@cvs.openbsd.org>2002-08-08 00:47:34 +0000
commit0fbf6e856c6c92dac5d02bc2a4ead2a6b5d3e569 (patch)
tree849a419513e0cabf6c01d0600350e2f928522073
parent4c8ac5756458c4eabf32ebe976c03b96aeb51d46 (diff)
if getcwd fails and we continue dont restcwd.
-rw-r--r--bin/systrace/intercept.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c
index 22b58142b09..0db979eb136 100644
--- a/bin/systrace/intercept.c
+++ b/bin/systrace/intercept.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: intercept.c,v 1.27 2002/08/07 21:27:15 provos Exp $ */
+/* $OpenBSD: intercept.c,v 1.28 2002/08/08 00:47:33 provos Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -527,17 +527,20 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp)
{
static char cwd[2*MAXPATHLEN];
char *name;
+ int norescwd = 0;
name = intercept_get_string(fd, pid, addr);
if (name == NULL)
goto abort;
- if (intercept.getcwd(fd, pid, cwd, sizeof(cwd)) == NULL)
+ if (intercept.getcwd(fd, pid, cwd, sizeof(cwd)) == NULL) {
if (name[0] != '/') {
if (errno == EBUSY)
goto abort;
err(1, "%s: getcwd", __func__);
}
+ norescwd = 1;
+ }
if (name[0] != '/') {
if (strlcat(cwd, "/", sizeof(cwd)) >= sizeof(cwd))
@@ -616,7 +619,7 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp)
/* Restore working directory and change root space after realpath */
- if (intercept.restcwd(fd) == -1)
+ if (!norescwd && intercept.restcwd(fd) == -1)
err(1, "%s: restcwd", __func__);
return (name);