Fix segfault on missing Sec-WebSocket-Key

This commit is contained in:
Přemysl Eric Janouch 2017-02-06 18:28:53 +01:00
parent a785dc9670
commit c4ebf2ccd5
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 3 additions and 0 deletions

View File

@ -1012,6 +1012,9 @@ ws_handler_finish_handshake (struct ws_handler *self)
const char *version = str_map_find (&self->headers, SEC_WS_VERSION);
const char *protocol = str_map_find (&self->headers, SEC_WS_PROTOCOL);
if (!key)
FAIL_HANDSHAKE (HTTP_400_BAD_REQUEST, NULL);
struct str tmp;
str_init (&tmp);
bool key_is_valid = base64_decode (key, false, &tmp) && tmp.len == 16;