Skip to content

Commit

Permalink
makes pcap_findalldevs_ex errors out if the directory does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
vwvw authored and guyharris committed Aug 19, 2024
1 parent 747fcb1 commit 0f8a103
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4826,14 +4826,21 @@ pcap_findalldevs_ex(const char *source, struct pcap_rmtauth *auth _USED_FOR_REMO
#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 (PCAP_ERROR);
}

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

if (filedata == NULL) {
DIAG_OFF_FORMAT_TRUNCATION
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Error when listing files: does folder '%s' exist?", path);
"Error when listing files: does folder '%s' contain files?", path);
DIAG_ON_FORMAT_TRUNCATION
closedir(unixdir);
return (PCAP_ERROR);
Expand Down

0 comments on commit 0f8a103

Please sign in to comment.