From e991c1f24f4f1ca48a4a068d332fc30f33886616 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Fri, 9 Mar 2012 10:51:29 -0700 Subject: [PATCH] Add (failing) CGI test, break some broken env code --- eris.c | 16 ++++++++++------ test.sh | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/eris.c b/eris.c index 967a42c..5487f69 100644 --- a/eris.c +++ b/eris.c @@ -75,9 +75,9 @@ int portappend = 0; /* Variables that persist between requests */ int cwd; int keepalive = 0; -char *remote_ip = NULL; -char *remote_port = NULL; -char *remote_ident = NULL; +char remote_ip[60] = {0}; +char remote_port[10] = {0}; +char remote_ident[80] = {0}; /* * Things that are really super convenient to have globally. @@ -205,6 +205,7 @@ get_ucspi_env() if (ucspi) { int protolen = strlen(ucspi); char buf[80]; + char *p; if (protolen > 20) { return; @@ -212,13 +213,16 @@ get_ucspi_env() strcpy(buf, ucspi); strcpy(buf + protolen, "REMOTEIP"); - remote_ip = getenv(buf); + p = getenv(buf); + strncpy(remote_ip, p, sizeof remote_ip); strcpy(buf + protolen, "REMOTEPORT"); - remote_port = getenv(buf); + p = getenv(buf); + strncpy(remote_port, p, sizeof remote_port); strcpy(buf + protolen, "REMOTEINFO"); - remote_ident = getenv(buf); + p = getenv(buf); + strncpy(remote_ident, p, sizeof remote_ident); } } diff --git a/test.sh b/test.sh index fb97b4d..861f722 100755 --- a/test.sh +++ b/test.sh @@ -166,8 +166,10 @@ printf 'POST /a.cgi HTTP/1.0\r\nContent-Type: moo\r\nContent-Length: 3\r\n\r\nar $HTTPD_CGI 2>/dev/null | d | grep -Eq '%CONTENT_LENGTH=.?3.?%CONTENT_TYPE=.?moo.?%' && pass || fail title "PATH_INFO" -printf 'GET /a.cgi/merf HTTP/1.0\r\n\r\n' | $HTTPD_CGI 2>/dev/null | grep -q '^PATH_INFO=/merf$' && pass || fail +printf 'GET /a.cgi/merf HTTP/1.0\r\n\r\n' | $HTTPD_CGI 2>/dev/null | grep -Eq '^PATH_INFO=.?/merf.?$' && pass || fail +title "SERVER_PROTOCOL" +printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | $HTTPD_CGI 2>/dev/null | d | grep -Eq '%SERVER_PROTOCOL=.?HTTP/1.0[^#%]?%[^#%]' && pass || fail H "fnord bugs"