Fix (minor) problems found by ubsan
authorAlessandro Ghedini <alessandro@ghedini.me>
Sat, 17 Oct 2015 19:28:25 +0000 (21:28 +0200)
committerAndy Polyakov <appro@openssl.org>
Sat, 21 Nov 2015 13:21:04 +0000 (14:21 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/evp/scrypt.c
test/ssltest.c

index 26b4e596ba2bb7c6f5d16ba590a37cf6562a51d2..e609594a91e1ddd917fdd4232174d9f05f83b94d 100644 (file)
@@ -139,7 +139,7 @@ static void scryptROMix(unsigned char *B, uint64_t r, uint64_t N,
         *pV = *pB++;
         *pV |= *pB++ << 8;
         *pV |= *pB++ << 16;
         *pV = *pB++;
         *pV |= *pB++ << 8;
         *pV |= *pB++ << 16;
-        *pV |= *pB++ << 24;
+        *pV |= (uint32_t)*pB++ << 24;
     }
 
     for (i = 1; i < N; i++, pV += 32 * r)
     }
 
     for (i = 1; i < N; i++, pV += 32 * r)
index c46c211031ef0038811634191ecef2f7bd9c7841..1128ec83b850e9dc2d126c109e4a843bff2d0267 100644 (file)
@@ -454,7 +454,12 @@ static int verify_alpn(SSL *client, SSL *server)
     OPENSSL_free(alpn_selected);
     alpn_selected = NULL;
 
     OPENSSL_free(alpn_selected);
     alpn_selected = NULL;
 
-    if (client_proto_len != server_proto_len ||
+    if (client_proto_len != server_proto_len) {
+        BIO_printf(bio_stdout, "ALPN selected protocols differ!\n");
+        goto err;
+    }
+
+    if (client_proto != NULL &&
         memcmp(client_proto, server_proto, client_proto_len) != 0) {
         BIO_printf(bio_stdout, "ALPN selected protocols differ!\n");
         goto err;
         memcmp(client_proto, server_proto, client_proto_len) != 0) {
         BIO_printf(bio_stdout, "ALPN selected protocols differ!\n");
         goto err;