Skip to content

Commit 0f8a103

Browse files
vwvwguyharris
authored andcommitted
makes pcap_findalldevs_ex errors out if the directory does not exist
1 parent 747fcb1 commit 0f8a103

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pcap.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4826,14 +4826,21 @@ pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth _USED_FOR_REMO
48264826
#else
48274827
/* opening the folder */
48284828
unixdir= opendir(path);
4829+
if (unixdir == NULL) {
4830+
DIAG_OFF_FORMAT_TRUNCATION
4831+
snprintf(errbuf, PCAP_ERRBUF_SIZE,
4832+
"Error when listing files: does folder '%s' exist?", path);
4833+
DIAG_ON_FORMAT_TRUNCATION
4834+
return (PCAP_ERROR);
4835+
}
48294836

48304837
/* get the first file into it */
48314838
filedata= readdir(unixdir);
48324839

48334840
if (filedata == NULL) {
48344841
DIAG_OFF_FORMAT_TRUNCATION
48354842
snprintf(errbuf, PCAP_ERRBUF_SIZE,
4836-
"Error when listing files: does folder '%s' exist?", path);
4843+
"Error when listing files: does folder '%s' contain files?", path);
48374844
DIAG_ON_FORMAT_TRUNCATION
48384845
closedir(unixdir);
48394846
return (PCAP_ERROR);

0 commit comments

Comments
 (0)