[Libwebsockets] [PATCH] client: fix verification of the accepted protocol

Alejandro Mery amery at geeks.cl
Wed Dec 10 00:52:33 CET 2014


to properly take ", *" as delimiter

Signed-off-by: Alejandro Mery <amery at geeks.cl>
---
 lib/client.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/client.c b/lib/client.c
index 4a094a8..b1a345b 100755
--- a/lib/client.c
+++ b/lib/client.c
@@ -562,13 +562,15 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
 
 	while (pc && *pc && !okay) {
 		if (!strncmp(pc, p, len) &&
-					  (pc[len] == ',' || pc[len] == '\0')) {
+		    (pc[len] == ',' || pc[len] == '\0')) {
 			okay = 1;
 			continue;
 		}
-		while (*pc && *pc != ',')
-			pc++;
-		while (*pc && *pc != ' ')
+		while (*pc) {
+			if (*pc++ == ',')
+				break;
+		}
+		while (*pc && *pc == ' ')
 			pc++;
 	}
 
-- 
2.2.0




More information about the Libwebsockets mailing list