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
(backported from commit 0f8a103)
  • Loading branch information
vwvw authored and guyharris committed Aug 20, 2024
1 parent e83c9f0 commit 8a633ee
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pcap-new.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,21 @@ 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);

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;
Expand Down

0 comments on commit 8a633ee

Please sign in to comment.