diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-03 15:01:50 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-03 15:01:50 +0100 |
commit | 12931edab795b7caeb70323e2959b5e5503c5980 (patch) | |
tree | e87a58862d07d6a3dec7ff396673e1f22a98b57f /client.c | |
parent | 73c843c1186c74e897022a3edb88d0d4f0ff27dc (diff) |
fix use-after-realloc issue with the request url
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -142,9 +142,9 @@ static int client_parse_request(struct client *cl, char *data) if (!type || !path || !version) return CLIENT_STATE_DONE; - memset(&cl->request, 0, sizeof(cl->request)); - req->url = path; + blobmsg_add_string(&cl->hdr, "URL", path); + memset(&cl->request, 0, sizeof(cl->request)); h_method = find_idx(http_methods, ARRAY_SIZE(http_methods), type); h_version = find_idx(http_versions, ARRAY_SIZE(http_versions), version); if (h_method < 0 || h_version < 0) { @@ -168,9 +168,8 @@ static bool client_init_cb(struct client *cl, char *buf, int len) *newline = 0; blob_buf_init(&cl->hdr, 0); - blobmsg_add_string(&cl->hdr, "REQUEST", buf); + cl->state = client_parse_request(cl, buf); ustream_consume(cl->us, newline + 2 - buf); - cl->state = client_parse_request(cl, (char *) blobmsg_data(blob_data(cl->hdr.head))); if (cl->state == CLIENT_STATE_DONE) uh_header_error(cl, 400, "Bad Request"); |