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:
Deomid Ryabkov 2020-08-19 21:48:45 +01:00
parent 0a09b46c94
commit a369160296
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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;