From 8a633ee5b9ecd9d38a587ac9b204e2380713b0d6 Mon Sep 17 00:00:00 2001 From: Nicolas Badoux Date: Mon, 19 Aug 2024 12:31:53 +0200 Subject: [PATCH] makes pcap_findalldevs_ex errors out if the directory does not exist (backported from commit 0f8a103469ce87d2b8d68c5130a46ddb7fb5eb29) Upstream-Status: Backport [https://github.com/the-tcpdump-group/libpcap/commit/8a633ee5b9ecd9d38a587ac9b204e2380713b0d6] CVE: CVE-2024-8006 Signed-off-by: Vijay Anusuri --- pcap-new.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pcap-new.c b/pcap-new.c index 7c00659..ac88065 100644 --- a/pcap-new.c +++ b/pcap-new.c @@ -231,13 +231,18 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t #else /* opening the folder */ unixdir= opendir(path); + if (unixdir == NULL) { + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Error when listing files: does folder '%s' exist?", path); + return -1; + } /* get the first file into it */ filedata= readdir(unixdir); if (filedata == NULL) { - snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path); + snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' contain files?", path); return -1; } #endif -- 2.25.1