]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Add missing check for nl_socket_alloc failure
authorArne Schwabe <arne@rfc2549.org>
Tue, 21 Nov 2023 17:06:03 +0000 (18:06 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 2 Dec 2023 15:56:35 +0000 (16:56 +0100)
This can happen if the memory alloc fails.

Patch V2: add goto error
Patch V3: return -ENOMEM instead of going to error

Change-Id: Iee66caa794d267ac5f8bee584633352893047171
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20231121170603.886801-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27541.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/dco_linux.c

index b033f8543ea08a4ade59795679dc9ab90aca76ac..3c91606b7311879f5d3a207505cf17a62819c226 100644 (file)
@@ -81,6 +81,12 @@ resolve_ovpn_netlink_id(int msglevel)
     int ret;
     struct nl_sock *nl_sock = nl_socket_alloc();
 
+    if (!nl_sock)
+    {
+        msg(msglevel, "Allocating net link socket failed");
+        return -ENOMEM;
+    }
+
     ret = genl_connect(nl_sock);
     if (ret)
     {