aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2023-08-01 02:20:32 -0700
committerGuy Harris <gharris@sonic.net>2023-08-01 02:20:32 -0700
commit3e33dc90bbd824cba7a4ef8779998fd369fbb52e (patch)
tree5ff10281831e8d6309e9d6da49c9a6ec68582ff8
parent5daaba1b5d45d111cbd4348d6d4e77fca12953a9 (diff)
pcap-linux: plug an FD leak.
If map_arphrd_to_dlt() fails, free sock_fd before returning the error status, as we do elsewhere. Fixes Coverity CID 1539177.
-rw-r--r--pcap-linux.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index 7af8af50..639d67d1 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -2405,8 +2405,10 @@ setup_socket(pcap_t *handle, int is_any_device)
return arptype;
}
status = map_arphrd_to_dlt(handle, arptype, device, 1);
- if (status < 0)
+ if (status < 0) {
+ close(sock_fd);
return status;
+ }
if (handle->linktype == -1 ||
handle->linktype == DLT_LINUX_SLL ||
handle->linktype == DLT_LINUX_IRDA ||