44 lines
1.5 KiB
Diff
44 lines
1.5 KiB
Diff
From 8a633ee5b9ecd9d38a587ac9b204e2380713b0d6 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] makes pcap_findalldevs_ex errors out if the directory does
|
|
not exist
|
|
|
|
(backported from commit 0f8a103469ce87d2b8d68c5130a46ddb7fb5eb29)
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/the-tcpdump-group/libpcap/commit/8a633ee5b9ecd9d38a587ac9b204e2380713b0d6
|
|
|
|
---
|
|
pcap-new.c | 9 ++++++++-
|
|
1 file changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/pcap-new.c b/pcap-new.c
|
|
index be91b3f8db..d449ee623c 100644
|
|
--- a/pcap-new.c
|
|
+++ b/pcap-new.c
|
|
@@ -230,6 +230,13 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|
#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);
|
|
@@ -237,7 +244,7 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
|
|
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;
|
|
|