From 72e31ba5f7cc18820c3b307aa1299bd859513f41 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 30 Aug 2019 13:08:09 +0100 Subject: [PATCH] ws role: cannot assume sentinel, use vhost count Protocol list is no longer a simple sentinel-terminated array but composed at vhost creation time in many cases. Use the vhost's count of how many protocols it has rather than seeking up to the sentinel. --- lib/roles/http/server/server.c | 2 +- lib/roles/ws/client-ws.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c index d4dc9a567..989994d42 100644 --- a/lib/roles/http/server/server.c +++ b/lib/roles/http/server/server.c @@ -1516,7 +1516,7 @@ lws_http_action(struct lws *wsi) if (lws_bind_protocol(wsi, pp, "http action CALLBACK bind")) return 1; - lwsl_notice("%s: %s, checking access rights for mask 0x%x\n", + lwsl_debug("%s: %s, checking access rights for mask 0x%x\n", __func__, hit->origin, hit->auth_mask); args.p = uri_ptr; diff --git a/lib/roles/ws/client-ws.c b/lib/roles/ws/client-ws.c index ee30bac66..6dc6d80f4 100644 --- a/lib/roles/ws/client-ws.c +++ b/lib/roles/ws/client-ws.c @@ -391,7 +391,7 @@ identify_protocol: if (!lwsi_role_client(wsi)) wsi->protocol = NULL; - while (wsi->vhost->protocols[n].callback) { + while (n < wsi->vhost->count_protocols) { if (!wsi->protocol && strcmp(p, wsi->vhost->protocols[n].name) == 0) { wsi->protocol = &wsi->vhost->protocols[n]; @@ -400,7 +400,7 @@ identify_protocol: n++; } - if (!wsi->vhost->protocols[n].callback) { /* no match */ + if (n == wsi->vhost->count_protocols) { /* no match */ /* if server, that's already fatal */ if (!lwsi_role_client(wsi)) { lwsl_info("%s: fail protocol %s\n", __func__, p);