summaryrefslogtreecommitdiffstats
path: root/cgi.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-07-11 22:27:35 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-07-11 22:27:35 +0000
commit44cfe1568557d7d58fab370a67aa425243a335b8 (patch)
tree370a9c41e22331bd51399193d48e89bde9dfb727 /cgi.c
parent6273b8a948dc78502b8197c70a1ed18548a053d0 (diff)
downloadmandoc-44cfe1568557d7d58fab370a67aa425243a335b8.tar.gz
merge OpenBSD rev. 1.3 by tedu@:
make http decode linear time. also remove a redundant null check.
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/cgi.c b/cgi.c
index 45e998ef..be6aa10b 100644
--- a/cgi.c
+++ b/cgi.c
@@ -165,7 +165,7 @@ html_printquery(const struct req *req)
}
if (NULL != req->q.expr) {
printf("&amp;expr=");
- html_print(req->q.expr ? req->q.expr : "");
+ html_print(req->q.expr);
}
}
@@ -284,11 +284,13 @@ static int
http_decode(char *p)
{
char hex[3];
+ char *q;
int c;
hex[2] = '\0';
- for ( ; '\0' != *p; p++) {
+ q = p;
+ for ( ; '\0' != *p; p++, q++) {
if ('%' == *p) {
if ('\0' == (hex[0] = *(p + 1)))
return(0);
@@ -299,13 +301,13 @@ http_decode(char *p)
if ('\0' == c)
return(0);
- *p = (char)c;
- memmove(p + 1, p + 3, strlen(p + 3) + 1);
+ *q = (char)c;
+ p += 2;
} else
- *p = '+' == *p ? ' ' : *p;
+ *q = '+' == *p ? ' ' : *p;
}
- *p = '\0';
+ *q = '\0';
return(1);
}