summaryrefslogtreecommitdiffstats
path: root/usr.sbin/slowcgi
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2014-04-16 14:43:43 +0000
committerflorian <florian@openbsd.org>2014-04-16 14:43:43 +0000
commit76f0500effe48b79da2fda8f2da28045472c4f96 (patch)
tree62120c6224b6b599cb29608ece984906cd95e558 /usr.sbin/slowcgi
parentWhitespace tweaks before further tweaks; no objections from ajacoutot@. (diff)
downloadwireguard-openbsd-76f0500effe48b79da2fda8f2da28045472c4f96.tar.xz
wireguard-openbsd-76f0500effe48b79da2fda8f2da28045472c4f96.zip
My previous attempt to chdir(2) to the directory containing the cgi
script was not quite right. slowcgi would try to chdir("") with a SCRIPT_NAME of /foo.cgi; chdir("/") in that case. I'm not sure how one would configure nginx/slowcgi to get to that point though. OK benno@
Diffstat (limited to 'usr.sbin/slowcgi')
-rw-r--r--usr.sbin/slowcgi/slowcgi.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c
index 215c466c52f..c27a74e2f7b 100644
--- a/usr.sbin/slowcgi/slowcgi.c
+++ b/usr.sbin/slowcgi/slowcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slowcgi.c,v 1.30 2014/04/14 19:25:48 florian Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.31 2014/04/16 14:43:43 florian Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
@@ -894,10 +894,15 @@ exec_cgi(struct request *c)
path = strrchr(c->script_name, '/');
if (path != NULL) {
- *path = '\0';
- if (chdir(c->script_name) == -1)
- lwarn("cannot chdir to %s", c->script_name);
- *path = '/';
+ if (path != c->script_name) {
+ *path = '\0';
+ if (chdir(c->script_name) == -1)
+ lwarn("cannot chdir to %s",
+ c->script_name);
+ *path = '/';
+ } else
+ if (chdir("/") == -1)
+ lwarn("cannot chdir to /");
}
argv[0] = c->script_name;