Correctly check for strncmp() return value (it returns 0 if the strings match).

Cheers
From 297c266f33ffb25e017bc005654ab3984da9b3e5 Mon Sep 17 00:00:00 2001
From: Alessandro Ghedini <alessan...@ghedini.me>
Date: Thu, 19 Feb 2015 19:55:59 +0100
Subject: [PATCH] polarssl: fix ALPN protocol negotiation

Correctly check for strncmp() return value (it returns 0 if the strings match).
---
 lib/vtls/polarssl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/vtls/polarssl.c b/lib/vtls/polarssl.c
index ca7e807..8b1f781 100644
--- a/lib/vtls/polarssl.c
+++ b/lib/vtls/polarssl.c
@@ -469,10 +469,11 @@ polarssl_connect_step2(struct connectdata *conn,
       infof(data, "ALPN, server accepted to use %s\n", next_protocol);
 
       if(strncmp(next_protocol, NGHTTP2_PROTO_VERSION_ID,
-                  NGHTTP2_PROTO_VERSION_ID_LEN)) {
+                  NGHTTP2_PROTO_VERSION_ID_LEN) == 0) {
         conn->negnpn = NPN_HTTP2;
       }
-      else if(strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)) {
+      else if(strncmp(next_protocol, ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH)
+                == 0) {
         conn->negnpn = NPN_HTTP1_1;
       }
     }
-- 
2.1.4

Attachment: signature.asc
Description: Digital signature

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to