projects
/
project
/
uhttpd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
proc: expose HTTP Origin header in process environment
[project/uhttpd.git]
/
cgi.c
diff --git
a/cgi.c
b/cgi.c
index
62be0a3
..
0ffb130
100644
(file)
--- a/
cgi.c
+++ b/
cgi.c
@@
-17,6
+17,7
@@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define _GNU_SOURCE
#include <libubox/blobmsg.h>
#include "uhttpd.h"
#include <libubox/blobmsg.h>
#include "uhttpd.h"
@@
-51,12
+52,12
@@
static void cgi_main(struct client *cl, struct path_info *pi, char *url)
setenv(var->name, var->value, 1);
}
setenv(var->name, var->value, 1);
}
- chdir(pi->root);
-
- if (ip)
- e
xecl(ip->path, ip->path, pi->phys, NULL);
- else
- execl(pi->phys, pi->phys, NULL);
+ if (!chdir(pi->root)) {
+ if (ip)
+ execl(ip->path, ip->path, pi->phys, NULL);
+ e
lse
+ execl(pi->phys, pi->phys, NULL);
+ }
printf("Status: 500 Internal Server Error\r\n\r\n"
"Unable to launch the requested CGI program:\n"
printf("Status: 500 Internal Server Error\r\n\r\n"
"Unable to launch the requested CGI program:\n"
@@
-103,7
+104,11
@@
static bool check_cgi_path(struct path_info *pi, const char *url)
}
pi->ip = NULL;
}
pi->ip = NULL;
- return uh_path_match(conf.cgi_docroot_path, pi->phys);
+
+ if (conf.cgi_docroot_path)
+ return uh_path_match(conf.cgi_docroot_path, pi->phys);
+
+ return false;
}
struct dispatch_handler cgi_dispatch = {
}
struct dispatch_handler cgi_dispatch = {