diff --git a/.gitignore b/.gitignore index fd50d0294..1fb8b7e09 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ doc /cros/ /q/ /b1/ +/destdir/ diff --git a/lib/roles/http/parsers.c b/lib/roles/http/parsers.c index d91b40d35..b74669b17 100644 --- a/lib/roles/http/parsers.c +++ b/lib/roles/http/parsers.c @@ -1065,12 +1065,18 @@ lws_parse(struct lws *wsi, unsigned char *buf, int *len) check_eol: /* bail at EOL */ if (ah->parser_state != WSI_TOKEN_CHALLENGE && - c == '\x0d') { + (c == '\x0d' || c == '\x0a')) { if (ah->ues != URIES_IDLE) goto forbid; + if (c == '\x0a') { + /* broken peer */ + ah->parser_state = WSI_TOKEN_NAME_PART; + ah->unk_pos = ah->lextable_pos = 0; + } else + ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR; + c = '\0'; - ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR; lwsl_parser("*\n"); } @@ -1095,6 +1101,10 @@ swallow: (unsigned long)lwsi_role(wsi), ah->lextable_pos); + if (!ah->unk_pos && c == '\x0a') + /* broken peer */ + goto set_parsing_complete; + if (c >= 'A' && c <= 'Z') c += 'a' - 'A'; /* @@ -1391,6 +1401,12 @@ excessive: case WSI_TOKEN_SKIPPING: lwsl_parser("WSI_TOKEN_SKIPPING '%c'\n", c); + if (c == '\x0a') { + /* broken peer */ + ah->parser_state = WSI_TOKEN_NAME_PART; + ah->unk_pos = ah->lextable_pos = 0; + } + if (c == '\x0d') ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR; break;