mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-07 16:01:30 +00:00
Do uri len check after it is finalised
This commit is contained in:
1 parent
e7459d91f9
commit
3256218fd2
2 files changed
+8
-6
No files matched your search
+4
-3
@@ -257,9 +257,6 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) {
|
||||
while (s < end && s[0] == ' ') s++; // Skip spaces
|
||||
if ((s = skiptorn(s, end, &hm->proto)) == NULL) return false;
|
||||
|
||||
// Sanity check. Allow protocol/reason to be empty
|
||||
if (hm->method.len == 0 || hm->uri.len == 0) return -1;
|
||||
|
||||
// If URI contains '?' character, setup query string
|
||||
if ((qs = (const char *) memchr(hm->uri.ptr, '?', hm->uri.len)) != NULL) {
|
||||
hm->query.ptr = qs + 1;
|
||||
@@ -267,6 +264,10 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) {
|
||||
hm->uri.len = (size_t) (qs - hm->uri.ptr);
|
||||
}
|
||||
|
||||
// Sanity check. Allow protocol/reason to be empty
|
||||
// Do this check after hm->method.len and hm->uri.len are finalised
|
||||
if (hm->method.len == 0 || hm->uri.len == 0) return -1;
|
||||
|
||||
if (!mg_http_parse_headers(s, end, hm->headers,
|
||||
sizeof(hm->headers) / sizeof(hm->headers[0])))
|
||||
return -1; // error when parsing
|
||||
|
||||
Reference in new issue
Block a user