projects
/
project
/
uhttpd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0cf1ced
)
fix error handling of invalid http method/version
author
Felix Fietkau
<nbd@openwrt.org>
Wed, 2 Jan 2013 18:35:21 +0000
(19:35 +0100)
committer
Felix Fietkau
<nbd@openwrt.org>
Wed, 2 Jan 2013 18:46:17 +0000
(19:46 +0100)
client.c
patch
|
blob
|
history
diff --git
a/client.c
b/client.c
index
c5b82d2
..
25cc271
100644
(file)
--- a/
client.c
+++ b/
client.c
@@
-134,6
+134,7
@@
static int client_parse_request(struct client *cl, char *data)
{
struct http_request *req = &cl->request;
char *type, *path, *version;
{
struct http_request *req = &cl->request;
char *type, *path, *version;
+ int h_method, h_version;
type = strtok(data, " ");
path = strtok(NULL, " ");
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;
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;
return CLIENT_STATE_DONE;
+ }
+
+ req->method = h_method;
+ req->version = h_version;
return CLIENT_STATE_HEADER;
}
return CLIENT_STATE_HEADER;
}