[Openvpn-devel,v1] iservice: check for NULL pointer

Message ID 20251123120029.19736-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] iservice: check for NULL pointer | expand

Commit Message

Gert Doering Nov. 23, 2025, noon UTC
From: Heiko Hund <heiko@ist.eigentlich.net>

Check if the list argument to ListContainsDomain() is NULL. Otherwise
the call to wcsstr() will bail out.

Reported-by: Marc Heuse <marc@srlabs.de>
Reported-by: stephan@srlabs.de
Change-Id: Icd7c7b08e317aefd91a60bfc62e92cd8707b6fac
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/+/1393
---

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/+/1393
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:37 p.m. UTC | #1
Trivial enough.  Stared-at-code, and buildbot did the compile tests.

I don't think this can ever happen in our context - search_domains
comes from a single call chain, and is initialized here

        PWSTR wide_search_domains;
        wide_search_domains = utf8to16(search_domains);
        if (!wide_search_domains)
        {
            return ERROR_OUTOFMEMORY;
        }  
        SetNrptExcludeRules(nrpt_key, ovpn_pid, wide_search_domains);
        free(wide_search_domains);

.. but this change does not hurt, and "if (NULL) return FALSE" matches
the function description "is 'domain' in 'list'? FALSE = no" just fine.

Your patch has been applied to the master branch.

commit 2e2ac94e9cf3d0bdb28339594c8236fa98784967
Author: Heiko Hund
Date:   Sun Nov 23 13:00:23 2025 +0100

     iservice: check for NULL pointer

     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/+/1393
     Message-Id: <20251123120029.19736-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34611.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 ec80a30..006f748 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -2106,7 +2106,7 @@ 
 ListContainsDomain(PCWSTR list, PCWSTR domain, size_t len)
 {
     PCWSTR match = list;
-    while (TRUE)
+    while (match)
     {
         match = wcsstr(match, domain);
         if (!match)