libpcap/libpcap-CVE-2024-8006.patch

38 lines
1.3 KiB
Diff

From 7bfeb10956692e5ef0fe435090144be35d33dafc Mon Sep 17 00:00:00 2001
From: Nicolas Badoux <n.badoux@hotmail.com>
Date: Mon, 19 Aug 2024 12:31:53 +0200
Subject: [PATCH 1/2] makes pcap_findalldevs_ex errors out if the directory
does not exist
---
pcap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: libpcap-1.10.4/pcap-new.c
===================================================================
--- libpcap-1.10.4.orig/pcap-new.c
+++ libpcap-1.10.4/pcap-new.c
@@ -232,6 +232,13 @@ int pcap_findalldevs_ex(const char *sour
#else
/* opening the folder */
unixdir= opendir(path);
+ if (unixdir == NULL) {
+ DIAG_OFF_FORMAT_TRUNCATION
+ snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "Error when listing files: does folder '%s' exist?", path);
+ DIAG_ON_FORMAT_TRUNCATION
+ return -1;
+ }
/* get the first file into it */
filedata= readdir(unixdir);
@@ -239,7 +246,7 @@ int pcap_findalldevs_ex(const char *sour
if (filedata == NULL)
{
DIAG_OFF_FORMAT_TRUNCATION
- 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);
DIAG_ON_FORMAT_TRUNCATION
closedir(unixdir);
return -1;