From 3003e0a4220f66690778b3ef7247ad5b56b4a375 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Sat, 17 Oct 2015 21:28:25 +0200 Subject: [PATCH] Fix (minor) problems found by ubsan Reviewed-by: Rich Salz Reviewed-by: Richard Levitte --- crypto/evp/scrypt.c | 2 +- test/ssltest.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crypto/evp/scrypt.c b/crypto/evp/scrypt.c index 26b4e596ba..e609594a91 100644 --- a/crypto/evp/scrypt.c +++ b/crypto/evp/scrypt.c @@ -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++ << 24; + *pV |= (uint32_t)*pB++ << 24; } for (i = 1; i < N; i++, pV += 32 * r) diff --git a/test/ssltest.c b/test/ssltest.c index c46c211031..1128ec83b8 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -454,7 +454,12 @@ static int verify_alpn(SSL *client, SSL *server) 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; -- 2.34.1