From abc3a7859e875066568a5592ad25801597598b90 Mon Sep 17 00:00:00 2001 From: Rene Jager Date: Mon, 1 Dec 2014 16:28:03 +0100 Subject: [PATCH] fix for handling protocol name starting with other protocol name --- lib/client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/client.c b/lib/client.c index 1c210be74..8c17109d7 100755 --- a/lib/client.c +++ b/lib/client.c @@ -588,10 +588,12 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context, if (strcmp(p, context->protocols[n].name) == 0) { wsi->protocol = &context->protocols[n]; break; - } - if (strstr(context->protocols[n].name, p)) { - wsi->protocol = &context->protocols[n]; - break; + } else { + char* sp = strstr(context->protocols[n].name, p); + if (sp && (sp[len] == ',' || sp[len] == '\0')) { + wsi->protocol = &context->protocols[n]; + break; + } } n++; }