mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-05 21:18:32 +08:00
Merge pull request #1138 from rojer/1135
Add missing range check in mg_get_http_header()
This commit is contained in:
commit
36de38bd11
@ -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…
Reference in New Issue
Block a user