]> granicus.if.org Git - curl/commitdiff
nss: fix NPN/ALPN protocol negotiation
authorAlessandro Ghedini <alessandro@ghedini.me>
Thu, 19 Feb 2015 18:58:28 +0000 (19:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 19 Feb 2015 22:09:12 +0000 (23:09 +0100)
Correctly check for memcmp() return value (it returns 0 if the strings match).

This is not really important, since curl is going to use http/1.1 anyway, but
it's still a bug I guess.

lib/vtls/nss.c

index f55c4763e46dfcf003a1b32afc705313b956e311..16b9124f151050491630ef592aa15f9d9486718e 100644 (file)
@@ -718,12 +718,11 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg)
     }
 
     if(buflen == NGHTTP2_PROTO_VERSION_ID_LEN &&
-       memcmp(NGHTTP2_PROTO_VERSION_ID, buf, NGHTTP2_PROTO_VERSION_ID_LEN)
-       == 0) {
+       !memcmp(NGHTTP2_PROTO_VERSION_ID, buf, NGHTTP2_PROTO_VERSION_ID_LEN)) {
       conn->negnpn = NPN_HTTP2;
     }
-    else if(buflen == ALPN_HTTP_1_1_LENGTH && memcmp(ALPN_HTTP_1_1, buf,
-                                                     ALPN_HTTP_1_1_LENGTH)) {
+    else if(buflen == ALPN_HTTP_1_1_LENGTH &&
+            !memcmp(ALPN_HTTP_1_1, buf, ALPN_HTTP_1_1_LENGTH)) {
       conn->negnpn = NPN_HTTP1_1;
     }
   }