[Openvpn-devel,v1] test_packet_id: Add a check after malloc to ensure value is valid

Message ID 20260406074729.29903-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] test_packet_id: Add a check after malloc to ensure value is valid | expand

Commit Message

Gert Doering April 6, 2026, 7:47 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

cppcheck complains about a potential null pointer dereference
in reliable_get_num_output_sequenced_available. That is mostly
theoretical, but still add a check.

Change-Id: I64da2328591ef2b9ee7502e574c878651cdf356a
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1621
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1621
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering April 6, 2026, 10:01 a.m. UTC | #1
That's an easy one - test code, no dependencies on other patches, and
tests itself :-)

Your patch has been applied to the master branch.

commit cdb0fbde266a3c3013c1354a985e82c33db8dcdb
Author: Frank Lichtenheld
Date:   Mon Apr 6 09:47:24 2026 +0200

     test_packet_id: Add a check after malloc to ensure value is valid

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1621
     Message-Id: <20260406074729.29903-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36516.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/tests/unit_tests/openvpn/test_packet_id.c b/tests/unit_tests/openvpn/test_packet_id.c
index b7538bd..5dfd319 100644
--- a/tests/unit_tests/openvpn/test_packet_id.c
+++ b/tests/unit_tests/openvpn/test_packet_id.c
@@ -164,6 +164,7 @@ 
 test_get_num_output_sequenced_available(void **state)
 {
     struct reliable *rel = malloc(sizeof(struct reliable));
+    assert_non_null(rel);
     reliable_init(rel, 100, 50, 8, false);
 
     rel->array[5].active = true;