]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix PACKET_equal test with BUF_LEN+1 on -Wstringop-overread
authorReinhard Urban <reinhard.urban@nubix.de>
Fri, 28 Oct 2022 07:56:05 +0000 (09:56 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 7 Nov 2022 18:21:56 +0000 (19:21 +0100)
Either suppress the error, or better make smbuf longer.
Detected with -Werror.

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19528)

test/packettest.c

index c62247f9be7b4c360b9bfc421e3d0673f8206886..68b6d679b96a36cfb2b0938cf09bc9f25865816b 100644 (file)
 
 #define BUF_LEN 255
 
-static unsigned char smbuf[BUF_LEN];
+static unsigned char smbuf[BUF_LEN + 1];
 
 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, BUF_LEN))
             || !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)
@@ -33,7 +33,7 @@ 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, BUF_LEN))
             || !TEST_size_t_eq(PACKET_remaining(&pkt), BUF_LEN)
             || !TEST_ptr_eq(PACKET_end(&pkt), smbuf + BUF_LEN)
             || !TEST_true(PACKET_forward(&pkt, BUF_LEN - 1))