mirror of https://github.com/nealey/eris.git
Quit setting environment variables to NULL
This commit is contained in:
parent
4ee3918c15
commit
ef5bf33e3e
20
cgi.c
20
cgi.c
|
@ -7,20 +7,20 @@ sigchld(int sig)
|
|||
static void
|
||||
cgi_child(const char *relpath)
|
||||
{
|
||||
setenv("GATEWAY_INTERFACE", "CGI/1.1", 1);
|
||||
setenv("SERVER_SOFTWARE", FNORD, 1);
|
||||
setenv("REQUEST_URI", path, 1);
|
||||
setenv("SERVER_NAME", host, 1);
|
||||
setenv("SCRIPT_NAME", relpath, 1);
|
||||
setenv("REMOTE_ADDR", remote_ip, 1);
|
||||
setenv("REMOTE_PORT", remote_port, 1);
|
||||
setenv("REMOTE_IDENT", remote_ident, 1);
|
||||
env("GATEWAY_INTERFACE", "CGI/1.1");
|
||||
env("SERVER_SOFTWARE", FNORD);
|
||||
env("REQUEST_URI", path);
|
||||
env("SERVER_NAME", host);
|
||||
env("SCRIPT_NAME", relpath);
|
||||
env("REMOTE_ADDR", remote_ip);
|
||||
env("REMOTE_PORT", remote_port);
|
||||
env("REMOTE_IDENT", remote_ident);
|
||||
if (content_length) {
|
||||
char cl[20];
|
||||
|
||||
snprintf(cl, sizeof cl, "%llu", (unsigned long long) content_length);
|
||||
setenv("CONTENT_LENGTH", cl, 1);
|
||||
setenv("CONTENT_TYPE", content_type, 1);
|
||||
env("CONTENT_LENGTH", cl);
|
||||
env("CONTENT_TYPE", content_type);
|
||||
}
|
||||
|
||||
execl(relpath, relpath, NULL);
|
||||
|
|
18
eris.c
18
eris.c
|
@ -172,6 +172,14 @@ badrequest(long code, const char *httpcomment, const char *message)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
void
|
||||
env(const char *k, const char *v)
|
||||
{
|
||||
if (v) {
|
||||
setenv(k, v, 1);
|
||||
}
|
||||
}
|
||||
|
||||
#include "cgi.c"
|
||||
|
||||
void
|
||||
|
@ -467,7 +475,7 @@ find_serve_file(char *relpath)
|
|||
|
||||
if ((p = strstr(relpath, ".cgi"))) {
|
||||
p += 4;
|
||||
setenv("PATH_INFO", p, 1);
|
||||
env("PATH_INFO", p);
|
||||
*p = 0;
|
||||
if (! stat(relpath, &st)) {
|
||||
close(fd);
|
||||
|
@ -520,7 +528,7 @@ handle_request()
|
|||
|
||||
if (docgi) {
|
||||
p[-2] = 0;
|
||||
setenv("REQUEST_METHOD", request, 1);
|
||||
env("REQUEST_METHOD", request);
|
||||
}
|
||||
|
||||
/* Interpret path into fspath. */
|
||||
|
@ -569,7 +577,7 @@ handle_request()
|
|||
*(p++) = 0; /* NULL-terminate path */
|
||||
|
||||
if (docgi && query_string) {
|
||||
setenv("QUERY_STRING", query_string, 1);
|
||||
env("QUERY_STRING", query_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,7 +595,7 @@ handle_request()
|
|||
keepalive = 0;
|
||||
}
|
||||
if (docgi) {
|
||||
setenv("SERVER_PROTOCOL", p, 1);
|
||||
env("SERVER_PROTOCOL", p);
|
||||
}
|
||||
|
||||
/* Read header fields */
|
||||
|
@ -635,7 +643,7 @@ handle_request()
|
|||
|
||||
/* Set up CGI environment variables */
|
||||
if (docgi) {
|
||||
setenv(cgi_name, val, 1);
|
||||
env(cgi_name, val);
|
||||
}
|
||||
|
||||
/* By default, re-use buffer space */
|
||||
|
|
Loading…
Reference in New Issue