From 633e80d2469e87e70cd90b0bf8ccca4c81561b46 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 11 Jul 2014 22:27:35 +0000 Subject: merge OpenBSD rev. 1.3 by tedu@: make http decode linear time. also remove a redundant null check. --- cgi.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'cgi.c') diff --git a/cgi.c b/cgi.c index c344943c..1672bffc 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.62 2014/07/11 22:25:44 schwarze Exp $ */ +/* $Id: cgi.c,v 1.63 2014/07/11 22:27:35 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -165,7 +165,7 @@ html_printquery(const struct req *req) } if (NULL != req->q.expr) { printf("&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); } -- cgit v1.2.3-56-ge451