[Openvpn-devel,v1] iservice: make sure buffer size is not zero

Message ID 20251123113747.17739-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] iservice: make sure buffer size is not zero | expand

Commit Message

Gert Doering Nov. 23, 2025, 11:37 a.m. UTC
From: Heiko Hund <heiko@ist.eigentlich.net>

GetItfDnsDomains expects a non-zero size buffer to return the domains
in. Check for the size as well, not just for a valid pointer.

Change-Id: I8b26c65415f5a751f416d80a22cbb7ff14aa27c0
Reported-by: Marc Heuse <marc@srlabs.de>
Reported-by: stephan@srlabs.de
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1389
---

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

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

Comments

Gert Doering Nov. 23, 2025, 1:21 p.m. UTC | #1
Trivial enough.

While this cannot happen today (the single caller passes in 
*size = sizeof(data[0].domains)), who knows what the next refactoring
might bring...

Not tested beyond "does BB confirm it compiles" - it does.  The failed
checks in BB look more like "something in one part of the build infra
is eating UDP fragments again" (some workers consistently fail t_client,
while all others are fine).

Your patch has been applied to the master branch.

commit c20a960a338a2e6e7436260cdae4d6eef298cfb0
Author: Heiko Hund
Date:   Sun Nov 23 12:37:42 2025 +0100

     iservice: make sure buffer size is not zero

     Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1389
     Message-Id: <20251123113747.17739-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34606.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index f64c247..d778e89 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -2149,7 +2149,7 @@ 
 static LSTATUS
 GetItfDnsDomains(HKEY itf, PCWSTR search_domains, PWSTR domains, PDWORD size)
 {
-    if (domains == NULL || size == 0)
+    if (domains == NULL || size == NULL || *size == 0)
     {
         return ERROR_INVALID_PARAMETER;
     }