1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

properly skip protocols with NULL name

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
This commit is contained in:
Denis Osvald 2015-12-21 16:39:59 +01:00 committed by Andy Green
parent 034e514a0d
commit 27174e64de

View file

@ -457,12 +457,9 @@ upgrade_ws:
lwsl_info("checking %s\n", protocol_name);
n = 0;
while (wsi->protocol && context->protocols[n].callback) {
if (!wsi->protocol->name) {
n++;
continue;
}
if (!strcmp(context->protocols[n].name,
while (context->protocols[n].callback) {
if (context->protocols[n].name &&
!strcmp(context->protocols[n].name,
protocol_name)) {
lwsl_info("prot match %d\n", n);
wsi->protocol = &context->protocols[n];
@ -477,19 +474,18 @@ upgrade_ws:
/* we didn't find a protocol he wanted? */
if (!hit) {
if (!lws_hdr_simple_ptr(wsi, WSI_TOKEN_PROTOCOL)) {
/*
* some clients only have one protocol and
* do not sent the protocol list header...
* allow it and match to protocol 0
*/
lwsl_info("defaulting to prot 0 handler\n");
wsi->protocol = &context->protocols[0];
} else {
lwsl_err("No protocol from list \"%s\" supported\n",
if (lws_hdr_simple_ptr(wsi, WSI_TOKEN_PROTOCOL)) {
lwsl_err("No protocol from \"%s\" supported\n",
protocol_list);
goto bail_nuke_ah;
}
/*
* some clients only have one protocol and
* do not sent the protocol list header...
* allow it and match to protocol 0
*/
lwsl_info("defaulting to prot 0 handler\n");
wsi->protocol = &context->protocols[0];
}
/* allocate wsi->user storage */
@ -509,7 +505,6 @@ upgrade_ws:
goto bail_nuke_ah;
}
/*
* Perform the handshake according to the protocol version the
* client announced