diff options
author | Pauli <paul.dale@oracle.com> | 2019-03-29 18:42:37 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-03-29 20:52:01 +1000 |
commit | 72962d025f875ac35114ac090b878ee18b246144 (patch) | |
tree | 4dd31617b30ff500a4d935d3fd2f5946583c4f9d | |
parent | 6fc1e6246f9b29334fd6dcb5b832e75cce7a2ecd (diff) | |
download | openssl-72962d025f875ac35114ac090b878ee18b246144.tar.gz |
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)
-rw-r--r-- | test/clienthellotest.c | 6 | ||||
-rw-r--r-- | test/packettest.c | 15 | ||||
-rw-r--r-- | test/servername_test.c | 8 | ||||
-rw-r--r-- | test/sslapitest.c | 6 |
4 files changed, 27 insertions, 8 deletions
diff --git a/test/clienthellotest.c b/test/clienthellotest.c index 7fdb5bc6fe..0afad6dbd6 100644 --- a/test/clienthellotest.c +++ b/test/clienthellotest.c @@ -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 diff --git a/test/packettest.c b/test/packettest.c index 81e0449bc9..41d938a68a 100644 --- a/test/packettest.c +++ b/test/packettest.c @@ -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; diff --git a/test/servername_test.c b/test/servername_test.c index f84c18705a..86d261f375 100644 --- a/test/servername_test.c +++ b/test/servername_test.c @@ -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 */ diff --git a/test/sslapitest.c b/test/sslapitest.c index 0a99277f87..bccf055f77 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -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) |