Correctly initialise PACKET to zero in the tests to avoid possible problems
with padding bytes. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8611)
This commit is contained in:
parent
6fc1e6246f
commit
72962d025f
4 changed files with 27 additions and 8 deletions
|
@ -58,7 +58,7 @@ static int test_client_hello(int currtest)
|
|||
BIO *wbio;
|
||||
long len;
|
||||
unsigned char *data;
|
||||
PACKET pkt = {0}, pkt2 = {0}, pkt3 = {0};
|
||||
PACKET pkt, pkt2, pkt3;
|
||||
char *dummytick = "Hello World!";
|
||||
unsigned int type = 0;
|
||||
int testresult = 0;
|
||||
|
@ -71,6 +71,10 @@ static int test_client_hello(int currtest)
|
|||
return 1;
|
||||
#endif
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
memset(&pkt2, 0, sizeof(pkt2));
|
||||
memset(&pkt3, 0, sizeof(pkt3));
|
||||
|
||||
/*
|
||||
* For each test set up an SSL_CTX and SSL and see what ClientHello gets
|
||||
* produced when we try to connect
|
||||
|
|
|
@ -350,8 +350,9 @@ static int test_PACKET_get_length_prefixed_1(void)
|
|||
unsigned char buf1[BUF_LEN];
|
||||
const size_t len = 16;
|
||||
unsigned int i;
|
||||
PACKET pkt, short_pkt, subpkt = {0};
|
||||
PACKET pkt, short_pkt, subpkt;
|
||||
|
||||
memset(&subpkt, 0, sizeof(subpkt));
|
||||
buf1[0] = (unsigned char)len;
|
||||
for (i = 1; i < BUF_LEN; i++)
|
||||
buf1[i] = (i * 2) & 0xff;
|
||||
|
@ -374,8 +375,9 @@ static int test_PACKET_get_length_prefixed_2(void)
|
|||
unsigned char buf1[1024];
|
||||
const size_t len = 516; /* 0x0204 */
|
||||
unsigned int i;
|
||||
PACKET pkt, short_pkt, subpkt = {0};
|
||||
PACKET pkt, short_pkt, subpkt;
|
||||
|
||||
memset(&subpkt, 0, sizeof(subpkt));
|
||||
for (i = 1; i <= 1024; i++)
|
||||
buf1[i - 1] = (i * 2) & 0xff;
|
||||
|
||||
|
@ -397,8 +399,9 @@ static int test_PACKET_get_length_prefixed_3(void)
|
|||
unsigned char buf1[1024];
|
||||
const size_t len = 516; /* 0x000204 */
|
||||
unsigned int i;
|
||||
PACKET pkt, short_pkt, subpkt = {0};
|
||||
PACKET pkt, short_pkt, subpkt;
|
||||
|
||||
memset(&subpkt, 0, sizeof(subpkt));
|
||||
for (i = 0; i < 1024; i++)
|
||||
buf1[i] = (i * 2) & 0xff;
|
||||
|
||||
|
@ -420,8 +423,9 @@ static int test_PACKET_as_length_prefixed_1(void)
|
|||
unsigned char buf1[BUF_LEN];
|
||||
const size_t len = 16;
|
||||
unsigned int i;
|
||||
PACKET pkt, exact_pkt, subpkt = {0};
|
||||
PACKET pkt, exact_pkt, subpkt;
|
||||
|
||||
memset(&subpkt, 0, sizeof(subpkt));
|
||||
buf1[0] = (unsigned char)len;
|
||||
for (i = 1; i < BUF_LEN; i++)
|
||||
buf1[i] = (i * 2) & 0xff;
|
||||
|
@ -443,8 +447,9 @@ static int test_PACKET_as_length_prefixed_2(void)
|
|||
unsigned char buf[1024];
|
||||
const size_t len = 516; /* 0x0204 */
|
||||
unsigned int i;
|
||||
PACKET pkt, exact_pkt, subpkt = {0};
|
||||
PACKET pkt, exact_pkt, subpkt;
|
||||
|
||||
memset(&subpkt, 0, sizeof(subpkt));
|
||||
for (i = 1; i <= 1024; i++)
|
||||
buf[i-1] = (i * 2) & 0xff;
|
||||
|
||||
|
|
|
@ -35,10 +35,16 @@ static int get_sni_from_client_hello(BIO *bio, char **sni)
|
|||
{
|
||||
long len;
|
||||
unsigned char *data;
|
||||
PACKET pkt = {0}, pkt2 = {0}, pkt3 = {0}, pkt4 = {0}, pkt5 = {0};
|
||||
PACKET pkt, pkt2, pkt3, pkt4, pkt5;
|
||||
unsigned int servname_type = 0, type = 0;
|
||||
int ret = 0;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
memset(&pkt2, 0, sizeof(pkt2));
|
||||
memset(&pkt3, 0, sizeof(pkt3));
|
||||
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))
|
||||
/* Skip the record header */
|
||||
|
|
|
@ -4595,12 +4595,16 @@ static int get_MFL_from_client_hello(BIO *bio, int *mfl_codemfl_code)
|
|||
{
|
||||
long len;
|
||||
unsigned char *data;
|
||||
PACKET pkt = {0}, pkt2 = {0}, pkt3 = {0};
|
||||
PACKET pkt, pkt2, pkt3;
|
||||
unsigned int MFL_code = 0, type = 0;
|
||||
|
||||
if (!TEST_uint_gt( len = BIO_get_mem_data( bio, (char **) &data ), 0 ) )
|
||||
goto end;
|
||||
|
||||
memset(&pkt, 0, sizeof(pkt));
|
||||
memset(&pkt2, 0, sizeof(pkt2));
|
||||
memset(&pkt3, 0, sizeof(pkt3));
|
||||
|
||||
if (!TEST_true( PACKET_buf_init( &pkt, data, len ) )
|
||||
/* Skip the record header */
|
||||
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH)
|
||||
|
|
Loading…
Reference in a new issue