mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-28 23:49:44 +08:00
Add missing range check in mg_get_http_header()
h/t BushraAloraini Fixes https://github.com/cesanta/mongoose/issues/1135
This commit is contained in:
parent
0a09b46c94
commit
a369160296
@ -6160,7 +6160,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
|
||||
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name) {
|
||||
size_t i, len = strlen(name);
|
||||
|
||||
for (i = 0; hm->header_names[i].len > 0; i++) {
|
||||
for (i = 0; i < MG_MAX_HTTP_HEADERS && hm->header_names[i].len > 0; i++) {
|
||||
struct mg_str *h = &hm->header_names[i], *v = &hm->header_values[i];
|
||||
if (h->p != NULL && h->len == len && !mg_ncasecmp(h->p, name, len))
|
||||
return v;
|
||||
|
@ -509,7 +509,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
|
||||
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name) {
|
||||
size_t i, len = strlen(name);
|
||||
|
||||
for (i = 0; hm->header_names[i].len > 0; i++) {
|
||||
for (i = 0; i < MG_MAX_HTTP_HEADERS && hm->header_names[i].len > 0; i++) {
|
||||
struct mg_str *h = &hm->header_names[i], *v = &hm->header_values[i];
|
||||
if (h->p != NULL && h->len == len && !mg_ncasecmp(h->p, name, len))
|
||||
return v;
|
||||
|
Loading…
x
Reference in New Issue
Block a user