diff options
author | Felix Fietkau <nbd@openwrt.org> | 2013-01-02 19:35:21 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2013-01-02 19:46:17 +0100 |
commit | a91df297fe85b29805a1a1591e9a6371b357f95c (patch) | |
tree | d9d2216573f46442748581f6a268696fc22f8459 | |
parent | 0cf1ced116843d5faba6326b23b5925a9d64c267 (diff) |
fix error handling of invalid http method/version
-rw-r--r-- | client.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -134,6 +134,7 @@ static int client_parse_request(struct client *cl, char *data) { struct http_request *req = &cl->request; char *type, *path, *version; + int h_method, h_version; type = strtok(data, " "); path = strtok(NULL, " "); @@ -143,13 +144,16 @@ static int client_parse_request(struct client *cl, char *data) memset(&cl->request, 0, sizeof(cl->request)); req->url = path; - req->method = find_idx(http_methods, ARRAY_SIZE(http_methods), type); - if (req->method < 0) - return CLIENT_STATE_DONE; - req->version = find_idx(http_versions, ARRAY_SIZE(http_versions), version); - if (cl->request.version < 0) + 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) { + req->version = UH_HTTP_VER_1_0; return CLIENT_STATE_DONE; + } + + req->method = h_method; + req->version = h_version; return CLIENT_STATE_HEADER; } |