diff --git a/lib/client.c b/lib/client.c index a7158d3fa..97d68fcc7 100755 --- a/lib/client.c +++ b/lib/client.c @@ -568,12 +568,12 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context, } while (*pc && *pc != ',') pc++; - while (*pc && *pc == ' ') + while (*pc && *pc != ' ') pc++; } if (!okay) { - lwsl_err("lws_client_int_s_hs: got bad protocol '%s'\n", p); + lwsl_err("lws_client_int_s_hs: got bad protocol %s\n", p); goto bail2; } @@ -591,7 +591,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context, } if (wsi->protocol == NULL) { - lwsl_err("lws_client_int_s_hs: fail protocol '%s'\n", p); + lwsl_err("lws_client_int_s_hs: fail protocol %s\n", p); goto bail2; } diff --git a/lib/server-handshake.c b/lib/server-handshake.c index ddfa275e5..9b6c81932 100644 --- a/lib/server-handshake.c +++ b/lib/server-handshake.c @@ -217,7 +217,10 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi) if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL)) { LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: "); - LWS_CPYAPP(p, wsi->protocol->name); + n = lws_hdr_copy(wsi, p, 128, WSI_TOKEN_PROTOCOL); + if (n < 0) + goto bail; + p += n; } #ifndef LWS_NO_EXTENSIONS diff --git a/lib/server.c b/lib/server.c index ec4d6bd68..4ed7f30f6 100644 --- a/lib/server.c +++ b/lib/server.c @@ -467,8 +467,6 @@ upgrade_ws: protocol_name[n] = '\0'; if (*p) p++; - while (*p == ' ') - p++; lwsl_info("checking %s\n", protocol_name);