From 625dc5e473f37ca15d521188dd219946f07732dc Mon Sep 17 00:00:00 2001 From: Emil Mikulic Date: Wed, 13 Dec 2006 08:38:18 +0000 Subject: [PATCH] - In decode_url() - Use '\0' instead of 0 to hint that it's in a character context. - Don't realloc - this wastes more time than it saves memory. - Don't forget to free decoded url if it's found to be unsafe! --- trunk/darkhttpd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trunk/darkhttpd.c b/trunk/darkhttpd.c index 74ef80f..2ae7fbb 100644 --- a/trunk/darkhttpd.c +++ b/trunk/darkhttpd.c @@ -1316,10 +1316,8 @@ static char *urldecode(const char *url) out[pos++] = url[i]; } } - out[pos] = 0; - - out = xrealloc(out, strlen(out)+1); /* dealloc what we don't need */ - return out; + out[pos] = '\0'; + return (out); } @@ -1769,6 +1767,7 @@ static void process_get(struct connection *conn) if (make_safe_uri(decoded_url) == NULL) { default_reply(conn, 400, "Bad Request", "You requested an invalid URI: %s", conn->uri); + free(decoded_url); return; }