fixing a crash if file was not valid
This commit is contained in:
@@ -13,23 +13,23 @@ Functions:
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
#include <yara.h>
|
#include <yara.h>
|
||||||
#include "app_ctrl.h"
|
#include "app_ctrl.h" //includes functions for controlling the application
|
||||||
#include "md5hash.h"
|
#include "md5hash.h" //includes functions for hashing files
|
||||||
#include "connect.h"
|
#include "connect.h" //includes functions for connecting to the server
|
||||||
#include "scan.h"
|
#include "scan.h" //includes functions for scanning files and folders
|
||||||
#include "queue_ctrl.h"
|
#include "queue_ctrl.h" //includes functions for controlling the queue
|
||||||
#include "well_known.h"
|
#include "well_known.h" //includes well known paths and file names e.g. com files
|
||||||
#include "local_com.h"
|
#include "local_com.h" //includes functions for handling local com files
|
||||||
#include "local_schedule.h"
|
#include "local_schedule.h" //includes functions for handling local schedule files
|
||||||
#include "log.h"
|
#include "log.h" //includes functions for logging
|
||||||
#include "thread_ctrl.h"
|
#include "thread_ctrl.h" //includes functions for controlling threads
|
||||||
#include "settings.h"
|
#include "settings.h" //includes functions for loading and updating settings
|
||||||
#include "check_dir.h"
|
#include "check_dir.h" //includes functions for checking directories
|
||||||
#include "virus_ctrl.h"
|
#include "virus_ctrl.h" //includes functions for controlling viruses and removing them
|
||||||
#include "update.h"
|
#include "update.h" //includes functions for updating the application
|
||||||
#include "check_process.h"
|
#include "check_process.h" //includes functions for checking processes and killing them
|
||||||
#include "utils.h"
|
#include "utils.h" //includes utility functions and non classified functions
|
||||||
#include "deepscan.h"
|
#include "deepscan.h" //includes functions for deep scanning files
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|||||||
@@ -148,7 +148,15 @@ void deepscan_folder(const std::string& directory) {
|
|||||||
}
|
}
|
||||||
//log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: Scanning file: ", full_path);
|
//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
|
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
|
if (fileSize > 4000000000) { // 4GB
|
||||||
log(LOGLEVEL::INFO_NOSEND, "[deepscan_folder()]: File too large to scan: ", full_path);
|
log(LOGLEVEL::INFO_NOSEND, "[deepscan_folder()]: File too large to scan: ", full_path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,8 +356,16 @@ void scan_file_t(const std::string& filepath_) {
|
|||||||
set_num_threads(get_num_threads() + 1);
|
set_num_threads(get_num_threads() + 1);
|
||||||
thread_local const std::string filepath(filepath_);
|
thread_local const std::string filepath(filepath_);
|
||||||
thread_local char* db_path = new char[300];
|
thread_local char* db_path = new char[300];
|
||||||
if(is_valid_path(filepath)){
|
if (is_valid_path(filepath)) { //filter out invalid paths and paths with weird characters
|
||||||
std::uintmax_t fileSize = std::filesystem::file_size(filepath);
|
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
|
if (fileSize > 4000000000) { // 4GB
|
||||||
log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", filepath);
|
log(LOGLEVEL::INFO_NOSEND, "[scan_folder()]: File too large to scan: ", filepath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user