diff options
author | Andy Green <andy@warmcat.com> | 2016-12-10 09:14:37 +0800 |
---|---|---|
committer | Dmitry Kovalenko <d.kovalenko@samsung.com> | 2016-12-16 11:19:28 +0300 |
commit | 348ec0844fbe1471c918d788df6aa0c1db82ba13 (patch) | |
tree | 489dc3d41647c5aa6849bea16a3a7da6822916dd | |
parent | d93d28416159b5501c1dc5bacc499ef83138ea2b (diff) | |
download | libwebsockets-accepted/tizen_3.0_ivi.tar.gz libwebsockets-accepted/tizen_3.0_ivi.tar.bz2 libwebsockets-accepted/tizen_3.0_ivi.zip |
ws-server: restrict returned Sec-Websocket-Protocol to the chosen name onlytizen_4.0.m1_releasesubmit/tizen_unified/20170308.100414submit/tizen_3.0/20161219.052244submit/tizen_3.0/20161219.052217submit/tizen_3.0.m2/20170104.093753submit/tizen/20161219.052346accepted/tizen/wearable/20161219.225107accepted/tizen/unified/20170309.040104accepted/tizen/tv/20161219.225048accepted/tizen/mobile/20161219.225030accepted/tizen/ivi/20161219.225127accepted/tizen/common/20161219.152124accepted/tizen/3.0/wearable/20161220.010508accepted/tizen/3.0/tv/20161220.010450accepted/tizen/3.0/mobile/20161220.010434accepted/tizen/3.0/ivi/20161220.010528accepted/tizen/3.0/common/20161220.101248accepted/tizen/3.0.m2/wearable/20170105.025032accepted/tizen/3.0.m2/tv/20170105.024907accepted/tizen/3.0.m2/mobile/20170105.024727tizen_3.0_tvtizen_3.0.m2accepted/tizen_wearableaccepted/tizen_tvaccepted/tizen_mobileaccepted/tizen_iviaccepted/tizen_commonaccepted/tizen_3.0_wearableaccepted/tizen_3.0_tvaccepted/tizen_3.0_mobileaccepted/tizen_3.0_iviaccepted/tizen_3.0_commonaccepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobile
https://libwebsockets.org/pipermail/libwebsockets/2016-November/002948.html
Updated to fix a problem with no protocol
https://github.com/warmcat/libwebsockets/issues/705
Change-Id: I06e9f9d5849e66291b246316008c6e2c5981a372
-rw-r--r-- | lib/server-handshake.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/server-handshake.c b/lib/server-handshake.c index 7328e5e2..ed257dea 100644 --- a/lib/server-handshake.c +++ b/lib/server-handshake.c @@ -214,7 +214,12 @@ handshake_0405(struct lws_context *context, struct lws *wsi) strcpy(p, (char *)pt->serv_buf); p += accept_len; - if (wsi->protocol->name && wsi->protocol->name[0]) { + /* we can only return the protocol header if: + * - one came in, and ... */ + if (lws_hdr_total_length(wsi, WSI_TOKEN_PROTOCOL) && + /* - it is not an empty string */ + wsi->protocol->name && + wsi->protocol->name[0]) { LWS_CPYAPP(p, "\x0d\x0aSec-WebSocket-Protocol: "); p += lws_snprintf(p, 128, "%s", wsi->protocol->name); } |