- 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!
This commit is contained in:
Emil Mikulic 2006-12-13 08:38:18 +00:00
parent ccea5116b5
commit 625dc5e473
1 changed files with 3 additions and 4 deletions

View File

@ -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;
}