test: fix coverity 1451534: improper use of negative value

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14638)
This commit is contained in:
Pauli 2021-03-22 12:46:12 +10:00
parent 69fb52e028
commit 66325793cc

View File

@ -52,8 +52,8 @@ static int get_sni_from_client_hello(BIO *bio, char **sni)
memset(&pkt4, 0, sizeof(pkt4));
memset(&pkt5, 0, sizeof(pkt5));
len = BIO_get_mem_data(bio, (char **)&data);
if (!TEST_true(PACKET_buf_init(&pkt, data, len))
if (!TEST_long_ge(len = BIO_get_mem_data(bio, (char **)&data), 0)
|| !TEST_true(PACKET_buf_init(&pkt, data, len))
/* Skip the record header */
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)
/* Skip the handshake message header */