Skip to contentSkip to conversation

Add missing check for nl_socket_alloc failure

PATCH Superseded Arne Schwabe 2 participants 2 messages Apr 25, 2023 – Apr 26, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add missing check for nl_socket_alloc failure

This can happen if the memory alloc fails.

Patch V2: add goto error

Change-Id Iee66caa794d267ac5f8bee584633352893047171
---
 src/openvpn/dco_linux.c | 7 +++++++
 1 file changed, 7 insertions(+)
src/openvpn/dco_linux.c +7 -0
index 41540c0f8..95fe94848 100644
@@ -83,6 +83,13 @@ 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");
+        ret = -1;
+        goto err_sock;
+    }
+
     ret = genl_connect(nl_sock);
     if (ret)
     {
Signature · 1 line
2.37.1 (Apple Git-137.1)
#1 lore raw

Hi,

Quoted 6 lines · Arne Schwabe

This can happen if the memory alloc fails.

Patch V2: add goto error

Change-Id Iee66caa794d267ac5f8bee584633352893047171

This patch seems to be a duplicate?
I also commented the "old v2".

Cheers,

Quoted 22 lines
---
  src/openvpn/dco_linux.c | 7 +++++++
  1 file changed, 7 insertions(+)
src/openvpn/dco_linux.c +7 -0
index 41540c0f8..95fe94848 100644
@@ -83,6 +83,13 @@ 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");
+        ret = -1;
+        goto err_sock;
+    }
+
      ret = genl_connect(nl_sock);
      if (ret)
      {
Signature · 4 lines
Antonio Quartulli

-- 
Antonio Quartulli