aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-02-06 18:28:53 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-02-06 18:28:53 +0100
commitc4ebf2ccd57c3c095b58de5f6c33019177306712 (patch)
treeb87cbb5986cef1b8c38bfd58c24deda47b4aaefb
parenta785dc96708d8edb5f2ae786a8deee7798523762 (diff)
downloadjson-rpc-shell-c4ebf2ccd57c3c095b58de5f6c33019177306712.tar.gz
json-rpc-shell-c4ebf2ccd57c3c095b58de5f6c33019177306712.tar.xz
json-rpc-shell-c4ebf2ccd57c3c095b58de5f6c33019177306712.zip
Fix segfault on missing Sec-WebSocket-Key
-rw-r--r--demo-json-rpc-server.c3
1 files changed, 3 insertions, 0 deletions
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;