summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2020-05-08 19:58:36 +0200
committerLeah Neukirchen <leah@vuxu.org>2020-05-08 19:58:36 +0200
commit800bcd41f5b38853c98bfdf48c5a71dcb33fe54f (patch)
tree1fd5f538f2f38e0daf93ec102b692a2f9f0b7472
parented1db11d24c5f99ce055720ca9e0a7433a6056d6 (diff)
downloadhittpd-800bcd41f5b38853c98bfdf48c5a71dcb33fe54f.tar.gz
hittpd-800bcd41f5b38853c98bfdf48c5a71dcb33fe54f.tar.xz
hittpd-800bcd41f5b38853c98bfdf48c5a71dcb33fe54f.zip
on_url: can be called multiple times for long URLs
-rw-r--r--hittpd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/hittpd.c b/hittpd.c
index d8ae501..c4a9f91 100644
--- a/hittpd.c
+++ b/hittpd.c
@@ -102,8 +102,13 @@ on_url(http_parser *p, const char *s, size_t l)
 {
 	struct conn_data *data = p->data;
 
-	if (!(data->path = strndup(s, l)))
+	size_t len = data->path ? strlen(data->path) : 0;
+	char *new = realloc(data->path, len + l + 1);
+	if (!new)
 		return 1;
+	data->path = new;
+	memcpy(data->path + len, s, l);
+	data->path[len + l] = 0;
 
 	return 0;
 }