Return a fatal error if application data is encountered during shutdown
[openssl.git] / test / packettest.c
index 83d1ccd3bb53366141b6d3214dbe6c15098309f9..e58d8d8bcfaa473d16af1d604785bc2b6bf8da1b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -18,12 +18,12 @@ static int test_PACKET_remaining(void)
 {
     PACKET pkt;
 
-    if (!TEST_true(PACKET_buf_init(&pkt, smbuf, sizeof(smbuf))
+    if (!TEST_true(PACKET_buf_init(&pkt, smbuf, sizeof(smbuf)))
             || !TEST_size_t_eq(PACKET_remaining(&pkt), BUF_LEN)
             || !TEST_true(PACKET_forward(&pkt, BUF_LEN - 1))
             || !TEST_size_t_eq(PACKET_remaining(&pkt), 1)
             || !TEST_true(PACKET_forward(&pkt, 1))
-            || !TEST_size_t_eq(PACKET_remaining(&pkt), 0)))
+            || !TEST_size_t_eq(PACKET_remaining(&pkt), 0))
         return 0;
 
     return 1;
@@ -33,13 +33,13 @@ static int test_PACKET_end(void)
 {
     PACKET pkt;
 
-    if (!TEST_true(PACKET_buf_init(&pkt, smbuf, sizeof(smbuf))
+    if (!TEST_true(PACKET_buf_init(&pkt, smbuf, sizeof(smbuf)))
             || !TEST_size_t_eq(PACKET_remaining(&pkt), BUF_LEN)
-            || !TEST_ptr_ne(PACKET_end(&pkt), smbuf + BUF_LEN)
+            || !TEST_ptr_eq(PACKET_end(&pkt), smbuf + BUF_LEN)
             || !TEST_true(PACKET_forward(&pkt, BUF_LEN - 1))
             || !TEST_ptr_eq(PACKET_end(&pkt), smbuf + BUF_LEN)
             || !TEST_true(PACKET_forward(&pkt, 1))
-            || !TEST_ptr_eq(PACKET_end(&pkt), smbuf + BUF_LEN)))
+            || !TEST_ptr_eq(PACKET_end(&pkt), smbuf + BUF_LEN))
         return 0;
 
     return 1;
@@ -47,7 +47,7 @@ static int test_PACKET_end(void)
 
 static int test_PACKET_get_1(void)
 {
-    unsigned int i;
+    unsigned int i = 0;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -64,7 +64,7 @@ static int test_PACKET_get_1(void)
 
 static int test_PACKET_get_4(void)
 {
-    unsigned long i;
+    unsigned long i = 0;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -81,7 +81,7 @@ static int test_PACKET_get_4(void)
 
 static int test_PACKET_get_net_2(void)
 {
-    unsigned int i;
+    unsigned int i = 0;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -98,7 +98,7 @@ static int test_PACKET_get_net_2(void)
 
 static int test_PACKET_get_net_3(void)
 {
-    unsigned long i;
+    unsigned long i = 0;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -115,7 +115,7 @@ static int test_PACKET_get_net_3(void)
 
 static int test_PACKET_get_net_4(void)
 {
-    unsigned long i;
+    unsigned long i = 0;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -133,7 +133,7 @@ static int test_PACKET_get_net_4(void)
 static int test_PACKET_get_sub_packet(void)
 {
     PACKET pkt, subpkt;
-    unsigned long i;
+    unsigned long i = 0;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
             || !TEST_true(PACKET_get_sub_packet(&pkt, &subpkt, 4))
@@ -153,7 +153,7 @@ static int test_PACKET_get_sub_packet(void)
 
 static int test_PACKET_get_bytes(void)
 {
-    const unsigned char *bytes;
+    const unsigned char *bytes = NULL;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -285,7 +285,7 @@ static int test_PACKET_contains_zero_byte(void)
 
 static int test_PACKET_forward(void)
 {
-    const unsigned char *byte;
+    const unsigned char *byte = NULL;
     PACKET pkt;
 
     if (!TEST_true(PACKET_buf_init(&pkt, smbuf, BUF_LEN))
@@ -352,7 +352,7 @@ static int test_PACKET_get_length_prefixed_1(void)
     unsigned int i;
     PACKET pkt, short_pkt, subpkt = {0};
 
-    buf1[0] = len;
+    buf1[0] = (unsigned char)len;
     for (i = 1; i < BUF_LEN; i++)
         buf1[i] = (i * 2) & 0xff;
 
@@ -422,7 +422,7 @@ static int test_PACKET_as_length_prefixed_1(void)
     unsigned int i;
     PACKET pkt, exact_pkt, subpkt = {0};
 
-    buf1[0] = len;
+    buf1[0] = (unsigned char)len;
     for (i = 1; i < BUF_LEN; i++)
         buf1[i] = (i * 2) & 0xff;
 
@@ -430,9 +430,9 @@ static int test_PACKET_as_length_prefixed_1(void)
             || !TEST_true(PACKET_buf_init(&exact_pkt, buf1, len + 1))
             || !TEST_false(PACKET_as_length_prefixed_1(&pkt, &subpkt))
             || !TEST_size_t_eq(PACKET_remaining(&pkt), BUF_LEN)
-            || !TEST_true(PACKET_as_length_prefixed_1(&exact_pkt, &subpkt)
+            || !TEST_true(PACKET_as_length_prefixed_1(&exact_pkt, &subpkt))
             || !TEST_size_t_eq(PACKET_remaining(&exact_pkt), 0)
-            || !TEST_size_t_eq(PACKET_remaining(&subpkt), len)))
+            || !TEST_size_t_eq(PACKET_remaining(&subpkt), len))
         return 0;
 
     return 1;