From c4ebf2ccd57c3c095b58de5f6c33019177306712 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Mon, 6 Feb 2017 18:28:53 +0100 Subject: Fix segfault on missing Sec-WebSocket-Key --- demo-json-rpc-server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demo-json-rpc-server.c b/demo-json-rpc-server.c index b2d804d..11ebfdf 100644 --- a/demo-json-rpc-server.c +++ b/demo-json-rpc-server.c @@ -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; -- cgit v1.2.3-70-g09d2