Skip to contentSkip to conversation

src/openvpn/dco_freebsd.c: handle malloc failure

PATCH In review Ilya Shipitsin 2 participants 2 messages May 18, 2023 – May 19, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 src/openvpn/dco_freebsd.c: handle malloc failure

malloc was not checked against NULL, I was able
to get core dump in case of failure

---
v2:
- style correction

 src/openvpn/dco_freebsd.c | 4 ++++
 1 file changed, 4 insertions(+)
src/openvpn/dco_freebsd.c +4 -0
index 1111abeb..af7776bb 100644
@@ -594,6 +594,10 @@ dco_available(int msglevel)
     }
 
     buf = malloc(ifcr.ifcr_total * IFNAMSIZ);
+    if (!buf)
+    {
+        goto out;
+    }
 
     ifcr.ifcr_count = ifcr.ifcr_total;
     ifcr.ifcr_buffer = buf;
Signature · 1 line
2.35.3.windows.1
Acked-by on v2 1/1
#1 lore raw

As discussed.

Tested with a basic client run on FreeBSD14 with DCO.

Your patch has been applied to the master and release/2.6 branch.

commit 5e79aed439d4e1b101c768aabfd695cd1c0a54ce (master) commit 73ce6ac984e3ab496f97979e41f2a27569a432fd (release/2.6)

Author: Ilya Shipitsin
Date:   Thu May 18 23:21:39 2023 +0200
     src/openvpn/dco_freebsd.c: handle malloc failure

     Signed-off-by: Ilya Shipitsin <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg26707.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering