diff --git a/src/client_backend/client_backend.cpp b/src/client_backend/client_backend.cpp index 0282334..cf2dd9d 100644 --- a/src/client_backend/client_backend.cpp +++ b/src/client_backend/client_backend.cpp @@ -13,23 +13,23 @@ Functions: #include #include #include -#include "app_ctrl.h" -#include "md5hash.h" -#include "connect.h" -#include "scan.h" -#include "queue_ctrl.h" -#include "well_known.h" -#include "local_com.h" -#include "local_schedule.h" -#include "log.h" -#include "thread_ctrl.h" -#include "settings.h" -#include "check_dir.h" -#include "virus_ctrl.h" -#include "update.h" -#include "check_process.h" -#include "utils.h" -#include "deepscan.h" +#include "app_ctrl.h" //includes functions for controlling the application +#include "md5hash.h" //includes functions for hashing files +#include "connect.h" //includes functions for connecting to the server +#include "scan.h" //includes functions for scanning files and folders +#include "queue_ctrl.h" //includes functions for controlling the queue +#include "well_known.h" //includes well known paths and file names e.g. com files +#include "local_com.h" //includes functions for handling local com files +#include "local_schedule.h" //includes functions for handling local schedule files +#include "log.h" //includes functions for logging +#include "thread_ctrl.h" //includes functions for controlling threads +#include "settings.h" //includes functions for loading and updating settings +#include "check_dir.h" //includes functions for checking directories +#include "virus_ctrl.h" //includes functions for controlling viruses and removing them +#include "update.h" //includes functions for updating the application +#include "check_process.h" //includes functions for checking processes and killing them +#include "utils.h" //includes utility functions and non classified functions +#include "deepscan.h" //includes functions for deep scanning files int main(int argc, char* argv[]) { diff --git a/src/client_backend/deepscan.cpp b/src/client_backend/deepscan.cpp index 04ead7f..2ca33d3 100644 --- a/src/client_backend/deepscan.cpp +++ b/src/client_backend/deepscan.cpp @@ -148,7 +148,15 @@ void deepscan_folder(const std::string& directory) { } //log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path); if (is_valid_path(full_path)) { // Filter out invalid paths and paths with weird characters - std::uintmax_t fileSize = std::filesystem::file_size(full_path); + std::uintmax_t fileSize = 0; + try { + fileSize = std::filesystem::file_size(full_path); + } + catch (std::filesystem::filesystem_error& e) { + log(LOGLEVEL::ERR_NOSEND, "[deepscan_folder()]: Could not get file size for file: ", full_path); + } + + //std::uintmax_t fileSize = std::filesystem::file_size(full_path); if (fileSize > 4000000000) { // 4GB log(LOGLEVEL::INFO_NOSEND, "[deepscan_folder()]: File too large to scan: ", full_path); } diff --git a/src/client_backend/scan.cpp b/src/client_backend/scan.cpp index ab1cf59..363fe8d 100644 --- a/src/client_backend/scan.cpp +++ b/src/client_backend/scan.cpp @@ -356,8 +356,16 @@ void scan_file_t(const std::string& filepath_) { set_num_threads(get_num_threads() + 1); thread_local const std::string filepath(filepath_); thread_local char* db_path = new char[300]; - if(is_valid_path(filepath)){ - std::uintmax_t fileSize = std::filesystem::file_size(filepath); + if (is_valid_path(filepath)) { //filter out invalid paths and paths with weird characters + std::uintmax_t fileSize = 0; + try { + fileSize = std::filesystem::file_size(filepath); + } + catch (std::filesystem::filesystem_error& e) { + log(LOGLEVEL::ERR_NOSEND, "[scan_file_t()]: Could not get file size for file: ", filepath); + set_num_threads(get_num_threads() - 1); + return; + } if (fileSize > 4000000000) { // 4GB log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", filepath); }