Skip to content

Commit 8a633ee

Browse files
vwvwguyharris
authored andcommitted
makes pcap_findalldevs_ex errors out if the directory does not exist
(backported from commit 0f8a103)
1 parent e83c9f0 commit 8a633ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pcap-new.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,21 @@ int pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth, pcap_if_t
230230
#else
231231
/* opening the folder */
232232
unixdir= opendir(path);
233+
if (unixdir == NULL) {
234+
DIAG_OFF_FORMAT_TRUNCATION
235+
snprintf(errbuf, PCAP_ERRBUF_SIZE,
236+
"Error when listing files: does folder '%s' exist?", path);
237+
DIAG_ON_FORMAT_TRUNCATION
238+
return -1;
239+
}
233240

234241
/* get the first file into it */
235242
filedata= readdir(unixdir);
236243

237244
if (filedata == NULL)
238245
{
239246
DIAG_OFF_FORMAT_TRUNCATION
240-
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' exist?", path);
247+
snprintf(errbuf, PCAP_ERRBUF_SIZE, "Error when listing files: does folder '%s' contain files?", path);
241248
DIAG_ON_FORMAT_TRUNCATION
242249
closedir(unixdir);
243250
return -1;

0 commit comments

Comments
 (0)