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:
parent
84f8137fa6
commit
04c20d7460
2 changed files with 19 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -61,3 +61,4 @@ doc
|
||||||
/cros/
|
/cros/
|
||||||
/q/
|
/q/
|
||||||
/b1/
|
/b1/
|
||||||
|
/destdir/
|
||||||
|
|
|
@ -1065,12 +1065,18 @@ lws_parse(struct lws *wsi, unsigned char *buf, int *len)
|
||||||
check_eol:
|
check_eol:
|
||||||
/* bail at EOL */
|
/* bail at EOL */
|
||||||
if (ah->parser_state != WSI_TOKEN_CHALLENGE &&
|
if (ah->parser_state != WSI_TOKEN_CHALLENGE &&
|
||||||
c == '\x0d') {
|
(c == '\x0d' || c == '\x0a')) {
|
||||||
if (ah->ues != URIES_IDLE)
|
if (ah->ues != URIES_IDLE)
|
||||||
goto forbid;
|
goto forbid;
|
||||||
|
|
||||||
c = '\0';
|
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;
|
ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
|
||||||
|
|
||||||
|
c = '\0';
|
||||||
lwsl_parser("*\n");
|
lwsl_parser("*\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,6 +1101,10 @@ swallow:
|
||||||
(unsigned long)lwsi_role(wsi),
|
(unsigned long)lwsi_role(wsi),
|
||||||
ah->lextable_pos);
|
ah->lextable_pos);
|
||||||
|
|
||||||
|
if (!ah->unk_pos && c == '\x0a')
|
||||||
|
/* broken peer */
|
||||||
|
goto set_parsing_complete;
|
||||||
|
|
||||||
if (c >= 'A' && c <= 'Z')
|
if (c >= 'A' && c <= 'Z')
|
||||||
c += 'a' - 'A';
|
c += 'a' - 'A';
|
||||||
/*
|
/*
|
||||||
|
@ -1391,6 +1401,12 @@ excessive:
|
||||||
case WSI_TOKEN_SKIPPING:
|
case WSI_TOKEN_SKIPPING:
|
||||||
lwsl_parser("WSI_TOKEN_SKIPPING '%c'\n", c);
|
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')
|
if (c == '\x0d')
|
||||||
ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
|
ah->parser_state = WSI_TOKEN_SKIPPING_SAW_CR;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue