]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
Prevent icmp_socket leak on error 515/head
authorMichal Sekletar <msekleta@redhat.com>
Tue, 27 Aug 2024 15:59:15 +0000 (17:59 +0200)
committerMichal Sekletar <msekleta@redhat.com>
Tue, 27 Aug 2024 16:01:23 +0000 (18:01 +0200)
packet/probe_unix.c

index 00ec7a25906b81bc586b9b7e56e2400543693daf..7362d6d8e4fe860571c755ce4cc1996d307c712a 100644 (file)
@@ -296,6 +296,7 @@ int open_ip4_sockets_dgram(
     }
 #ifdef HAVE_LINUX_ERRQUEUE_H
     if (setsockopt(icmp_socket, SOL_IP, IP_RECVERR, &val, sizeof(val)) < 0) {
+        close(icmp_socket);
         return -1;
     }
 #endif
@@ -386,6 +387,7 @@ int open_ip6_sockets_dgram(
     }
 #ifdef HAVE_LINUX_ERRQUEUE_H
     if (setsockopt(icmp_socket, SOL_IPV6, IPV6_RECVERR, &val, sizeof(val)) < 0) {
+        close(icmp_socket);
         return -1;
     }
 #endif