mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ws: connection parse: check just the resolved token
Add strncasecmp to correctly restrict the check to just the tokenizer token extent
This commit is contained in:
parent
f7149e90c2
commit
ae6346db64
2 changed files with 6 additions and 2 deletions
|
@ -134,8 +134,10 @@
|
|||
// Visual studio older than 2015 and WIN_CE has only _stricmp
|
||||
#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE)
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#elif !defined(__MINGW32__)
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
#define getdtablesize() 30000
|
||||
#endif
|
||||
|
|
|
@ -300,15 +300,17 @@ lws_client_ws_upgrade(struct lws *wsi, const char **cce)
|
|||
e = lws_tokenize(&ts);
|
||||
switch (e) {
|
||||
case LWS_TOKZE_TOKEN:
|
||||
if (!strcasecmp(ts.token, "upgrade"))
|
||||
if (!strncasecmp(ts.token, "upgrade", ts.token_len))
|
||||
e = LWS_TOKZE_ENDED;
|
||||
break;
|
||||
|
||||
case LWS_TOKZE_DELIMITER:
|
||||
break;
|
||||
|
||||
default: /* includes ENDED */
|
||||
default: /* includes ENDED found by the tokenizer itself */
|
||||
bad_conn_format:
|
||||
lwsl_info("%s: malfored connection '%s'\n",
|
||||
__func__, buf);
|
||||
*cce = "HS: UPGRADE malformed";
|
||||
goto bail3;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue