From: Nirmala Venkata Subbaiah -X (nirmvenk - XORIANT CORPORATION at Cisco) Date: Mon, 24 Mar 2025 17:19:11 +0000 (+0000) Subject: Pull request #4672: packet_capture: use existing util function to check directory... X-Git-Tag: 3.7.2.0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33c9aa7ed1e467a3ab6fb4782da5746cbfe1cd47;p=thirdparty%2Fsnort3.git Pull request #4672: packet_capture: use existing util function to check directory path Merge in SNORT/snort3 from ~NIRMVENK/snort3:fix_error to master Squashed commit of the following: commit 47e879770de81b34013c58c66f73713bbb2dcb42 Author: Nirmala Subbaiah Date: Fri Mar 21 13:24:01 2025 -0400 packet_capture: use existing util function to check directory path --- diff --git a/src/network_inspectors/packet_capture/capture_module.cc b/src/network_inspectors/packet_capture/capture_module.cc index 5555ec676..46eb102c1 100644 --- a/src/network_inspectors/packet_capture/capture_module.cc +++ b/src/network_inspectors/packet_capture/capture_module.cc @@ -24,7 +24,6 @@ #include "capture_module.h" -#include #include #include "control/control.h" @@ -254,7 +253,7 @@ PegCount* CaptureModule::get_counts() const bool is_path_valid(const std::string& path) { - if ( !std::filesystem::exists(path) ) + if ( !is_directory_path(path) ) { WarningMessage("Cannot create pcap at %s; directory does not exist\n", path.c_str()); return false; diff --git a/src/utils/util.cc b/src/utils/util.cc index 579efe040..8568b42b8 100644 --- a/src/utils/util.cc +++ b/src/utils/util.cc @@ -85,6 +85,8 @@ bool get_file_size(const std::string& path, size_t& size) return true; } +namespace snort +{ bool is_directory_path(const std::string& path) { struct STAT sb; @@ -95,8 +97,6 @@ bool is_directory_path(const std::string& path) return ISDIR(sb.st_mode); } -namespace snort -{ const char* get_error(int errnum) { static THREAD_LOCAL char buf[128]; diff --git a/src/utils/util.h b/src/utils/util.h index 993687530..f3302b512 100644 --- a/src/utils/util.h +++ b/src/utils/util.h @@ -65,7 +65,6 @@ unsigned int get_random_seed(); bool get_file_size(const std::string&, size_t&); -bool is_directory_path(const std::string&); namespace { @@ -119,6 +118,7 @@ SO_PUBLIC std::string int_vector_to_str(const std::vector& elems, char SO_PUBLIC bool rotate_file_for_max_size(const char* file_owner, const char* old_file, FILE* old_fh, uint32_t max_file_size); SO_PUBLIC bool check_file_size(FILE* fh, uint64_t max_file_size); +SO_PUBLIC bool is_directory_path(const std::string&); } #endif