From 5519d9f0544264fe71e0badd3d858d8ffbef2431 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Tue, 3 Apr 2012 17:22:19 +0100 Subject: [PATCH] handle unsupported protocol correctly Hi Andy, First off, thanks for libwebsockets :-) I've encountered a crash when a client connects to a libwebsockets server but speicifies an unsupported protocol (Sec-WebSocket-Protocol). handshake.c should probably be checking that wsi->protocol->name is not null before doing a strcmp with it... Attached is a patch for your consideration. Cheers! Nick Signed-off-by: Nick Dowell --- lib/handshake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/handshake.c b/lib/handshake.c index dafccef2..dca2e141 100644 --- a/lib/handshake.c +++ b/lib/handshake.c @@ -619,7 +619,7 @@ libwebsocket_read(struct libwebsocket_context *context, struct libwebsocket *wsi if (wsi->protocol->name == NULL) break; } else - if (strcmp( + if (wsi->protocol->name && strcmp( wsi->utf8_token[WSI_TOKEN_PROTOCOL].token, wsi->protocol->name) == 0) break;