1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-30 00:00:16 +01:00

ah: workaround for broken routers with no http header delimiter

There's a type of router in the wild issuing malformed http when
in captive portal mode... there's no \x0a\x0d but just \x0a
This commit is contained in:
Andy Green 2020-06-30 17:50:01 +01:00
parent 84f8137fa6
commit 04c20d7460
2 changed files with 19 additions and 2 deletions

1
.gitignore vendored
View file

@ -61,3 +61,4 @@ doc
/cros/
/q/
/b1/
/destdir/

View file

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