Skip to contentSkip to conversation

Change in openvpn[master]: dco_freebsd: Add check_malloc_return after realloc

Openvpn-devel In review flichtenheld (Code Review) 2 participants 7 messages May 6 – May 8 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1778102459000.Icd8ea093dfe9f1888570f3d7b786b951b5262e47@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email

to review the following change.

Change subject: dco_freebsd: Add check_malloc_return after realloc
......................................................................

dco_freebsd: Add check_malloc_return after realloc

cppcheck complained about a potential memleak
due to realloc failure. But trying to handle that
is probably not useful. Just abort like we do
for other malloc failures.

Change-Id Icd8ea093dfe9f1888570f3d7b786b951b5262e47

---
M dev-tools/cppcheck-suppression
M src/openvpn/dco_freebsd.c

2 files changed, 3 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/1669/1

dev-tools/cppcheck-suppression +2 -0
index 1fefb51..c9d4714 100644
@@ -49,6 +49,8 @@
 knownConditionTrueFalse:src/openvpnmsica/dllmain.c:164
 # FP: cppcheck seems to be confused since we cast the pointer to integer
 memleak:src/plugins/down-root/down-root.c:337
+# IGN: we just abort instead
+memleakOnRealloc:src/openvpn/dco_freebsd.c:845
 # FP: eventmsg.h is not built on Unix
 missingInclude:src/openvpnserv/common.c:25
 # IGN: strlen(NULL) is not nice code, but seems to work
src/openvpn/dco_freebsd.c +1 -0
index 718cd8b..eaca86b 100644
@@ -842,6 +842,7 @@
 
 retry:
     buf = realloc(buf, buf_size);
+    check_malloc_return(buf);
     drv.ifd_len = buf_size;
     drv.ifd_data = buf;
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icd8ea093dfe9f1888570f3d7b786b951b5262e47
Gerrit-Change-Number: 1669
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email )

Change subject: dco_freebsd: Add check_malloc_return after realloc
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icd8ea093dfe9f1888570f3d7b786b951b5262e47
Gerrit-Change-Number: 1669
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Thu, 07 May 2026 07:52:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 dco_freebsd: Add check_malloc_return after realloc

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

cppcheck complained about a potential memleak
due to realloc failure. But trying to handle that
is probably not useful. Just abort like we do
for other malloc failures.

Change-Id Icd8ea093dfe9f1888570f3d7b786b951b5262e47

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1669
---

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/+/1669
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

dev-tools/cppcheck-suppression +2 -0
index 1fefb51..c9d4714 100644
@@ -49,6 +49,8 @@
 knownConditionTrueFalse:src/openvpnmsica/dllmain.c:164
 # FP: cppcheck seems to be confused since we cast the pointer to integer
 memleak:src/plugins/down-root/down-root.c:337
+# IGN: we just abort instead
+memleakOnRealloc:src/openvpn/dco_freebsd.c:845
 # FP: eventmsg.h is not built on Unix
 missingInclude:src/openvpnserv/common.c:25
 # IGN: strlen(NULL) is not nice code, but seems to work
src/openvpn/dco_freebsd.c +1 -0
index 718cd8b..eaca86b 100644
@@ -842,6 +842,7 @@
 
 retry:
     buf = realloc(buf, buf_size);
+    check_malloc_return(buf);
     drv.ifd_len = buf_size;
     drv.ifd_data = buf;
 
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: dco_freebsd: Add check_malloc_return after realloc

Good find. Arguably this is a bug, even if in the "unlikely to ever happen" category, so backported to release/2.7 (without the cppcheck file).

Mildy tested on FreeBSD 14 + DCO (... after repairing the t_server setup).

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

commit fcc34b135222edf3d53976f406f8db19c19294c0 (master) commit 1a15b3fa51537592bfda1ea588e28f73ded39caf (release/2.7)

Author: Frank Lichtenheld
Date:   Thu May 7 09:53:15 2026 +0200
     dco_freebsd: Add check_malloc_return after realloc

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1669
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg36842.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email

to look at the new patch set (#2).

The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.

Change subject: dco_freebsd: Add check_malloc_return after realloc
......................................................................

dco_freebsd: Add check_malloc_return after realloc

cppcheck complained about a potential memleak
due to realloc failure. But trying to handle that
is probably not useful. Just abort like we do
for other malloc failures.

Change-Id Icd8ea093dfe9f1888570f3d7b786b951b5262e47

---
M dev-tools/cppcheck-suppression
M src/openvpn/dco_freebsd.c

2 files changed, 3 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/1669/2

dev-tools/cppcheck-suppression +2 -0
index f92f7f4..2e3350b 100644
@@ -62,6 +62,8 @@
 knownConditionTrueFalse:src/openvpnmsica/dllmain.c:164
 # FP: cppcheck seems to be confused since we cast the pointer to integer
 memleak:src/plugins/down-root/down-root.c:337
+# IGN: we just abort instead
+memleakOnRealloc:src/openvpn/dco_freebsd.c:845
 # FP: eventmsg.h is not built on Unix
 missingInclude:src/openvpnserv/common.c:25
 # IGN: strlen(NULL) is not nice code, but seems to work
src/openvpn/dco_freebsd.c +1 -0
index 718cd8b..eaca86b 100644
@@ -842,6 +842,7 @@
 
 retry:
     buf = realloc(buf, buf_size);
+    check_malloc_return(buf);
     drv.ifd_len = buf_size;
     drv.ifd_data = buf;
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icd8ea093dfe9f1888570f3d7b786b951b5262e47
Gerrit-Change-Number: 1669
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#6 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: dco_freebsd: Add check_malloc_return after realloc
......................................................................

dco_freebsd: Add check_malloc_return after realloc

cppcheck complained about a potential memleak
due to realloc failure. But trying to handle that
is probably not useful. Just abort like we do
for other malloc failures.

Change-Id Icd8ea093dfe9f1888570f3d7b786b951b5262e47

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1669
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36842.html

---
M dev-tools/cppcheck-suppression
M src/openvpn/dco_freebsd.c

2 files changed, 3 insertions(+), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/69/1669/3

dev-tools/cppcheck-suppression +2 -0
index 1f31edb..439cbb1 100644
@@ -44,6 +44,8 @@
 knownConditionTrueFalse:src/openvpnmsica/dllmain.c:164
 # FP: cppcheck seems to be confused since we cast the pointer to integer
 memleak:src/plugins/down-root/down-root.c:337
+# IGN: we just abort instead
+memleakOnRealloc:src/openvpn/dco_freebsd.c:845
 # FP: eventmsg.h is not built on Unix
 missingInclude:src/openvpnserv/common.c:25
 # IGN: strlen(NULL) is not nice code, but seems to work
src/openvpn/dco_freebsd.c +1 -0
index 718cd8b..eaca86b 100644
@@ -842,6 +842,7 @@
 
 retry:
     buf = realloc(buf, buf_size);
+    check_malloc_return(buf);
     drv.ifd_len = buf_size;
     drv.ifd_data = buf;
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icd8ea093dfe9f1888570f3d7b786b951b5262e47
Gerrit-Change-Number: 1669
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#7 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email )

Change subject: dco_freebsd: Add check_malloc_return after realloc
......................................................................

dco_freebsd: Add check_malloc_return after realloc

cppcheck complained about a potential memleak
due to realloc failure. But trying to handle that
is probably not useful. Just abort like we do
for other malloc failures.

Change-Id Icd8ea093dfe9f1888570f3d7b786b951b5262e47

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1669
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36842.html

---
M dev-tools/cppcheck-suppression
M src/openvpn/dco_freebsd.c

2 files changed, 3 insertions(+), 0 deletions(-)
dev-tools/cppcheck-suppression +2 -0
index 1f31edb..439cbb1 100644
@@ -44,6 +44,8 @@
 knownConditionTrueFalse:src/openvpnmsica/dllmain.c:164
 # FP: cppcheck seems to be confused since we cast the pointer to integer
 memleak:src/plugins/down-root/down-root.c:337
+# IGN: we just abort instead
+memleakOnRealloc:src/openvpn/dco_freebsd.c:845
 # FP: eventmsg.h is not built on Unix
 missingInclude:src/openvpnserv/common.c:25
 # IGN: strlen(NULL) is not nice code, but seems to work
src/openvpn/dco_freebsd.c +1 -0
index 718cd8b..eaca86b 100644
@@ -842,6 +842,7 @@
 
 retry:
     buf = realloc(buf, buf_size);
+    check_malloc_return(buf);
     drv.ifd_len = buf_size;
     drv.ifd_data = buf;
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1669?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icd8ea093dfe9f1888570f3d7b786b951b5262e47
Gerrit-Change-Number: 1669
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>