Skip to content

Commit

Permalink
Requested modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
lsayanes committed Jul 25, 2023
1 parent daa0a84 commit db44930
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/config/localfile-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ int Read_Localfile(XML_NODE node, void *d1, __attribute__((unused)) void *d2)
if (strchr(logf[pl].file, '*') ||
strchr(logf[pl].file, '?')) {

os_realloc(log_config->globs, (gl + 2) * sizeof(logreader_glob), log_config->globs);
os_realloc(log_config->globs, (gl + 2)*sizeof(logreader_glob), log_config->globs);
os_strdup(logf[pl].file, log_config->globs[gl].gpath);
memset(&log_config->globs[gl + 1], 0, sizeof(logreader_glob));
os_calloc(1, sizeof(logreader), log_config->globs[gl].gfiles);
Expand All @@ -648,7 +648,7 @@ int Read_Localfile(XML_NODE node, void *d1, __attribute__((unused)) void *d2)
if (logf[pl].exclude && strchr(logf[pl].exclude, '%')) {

time_t l_time = time(0);
char excluded_path_date[PATH_MAX] = { 0 };
char excluded_path_date[PATH_MAX] = {0};
size_t ret;
struct tm tm_result = { .tm_sec = 0 };

Expand All @@ -662,7 +662,7 @@ int Read_Localfile(XML_NODE node, void *d1, __attribute__((unused)) void *d2)
os_strdup(logf[pl].exclude, log_config->globs[gl].exclude_path);
}

if (Remove_Localfile(&logf, pl, 0, 0, NULL)) {
if (Remove_Localfile(&logf, pl, 0, 0,NULL)) {
merror(REM_ERROR, logf[pl].file);
return (OS_INVALID);
}
Expand Down
22 changes: 10 additions & 12 deletions src/logcollector/logcollector.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,7 @@ int check_pattern_expand(int do_seek) {
for (j = 0; globs[j].gpath; j++) {

if (current_files >= maximum_files) {
mwarn(FILE_LIMIT, maximum_files);
break;
}

Expand All @@ -1523,24 +1524,21 @@ int check_pattern_expand(int do_seek) {
if (result) {

int file;
int totalFiles = 0;
char *full_path = NULL;

while (NULL != result[totalFiles])
{
totalFiles++;
}
totalFiles %= maximum_files;
for (file = 0; result[file] != NULL; file++) {

for (file = 0; file < totalFiles; file++) {
if (current_files >= maximum_files) {
mwarn(FILE_LIMIT, maximum_files);
break;
}

os_strdup(result[file], full_path);

found = 0;
for (i = 0; globs[j].gfiles[i].file; i++) {
if (!strcmp(globs[j].gfiles[i].file, full_path)) {
found = 1;
os_free(full_path);
break;
}
}
Expand All @@ -1549,7 +1547,7 @@ int check_pattern_expand(int do_seek) {
retval = 1;
int added = 0;

char* ex_file = OSHash_Get(excluded_files, full_path);
char *ex_file = OSHash_Get(excluded_files, full_path);

if (!ex_file) {

Expand All @@ -1558,8 +1556,8 @@ int check_pattern_expand(int do_seek) {
HANDLE h1;

h1 = CreateFile(full_path, GENERIC_READ,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

if (h1 == INVALID_HANDLE_VALUE) {
os_free(full_path);
Expand Down Expand Up @@ -1592,7 +1590,7 @@ int check_pattern_expand(int do_seek) {
added = 1;
}

char* file_excluded_binary = OSHash_Get(excluded_binaries, full_path);
char *file_excluded_binary = OSHash_Get(excluded_binaries, full_path);

/* This file could have to non binary file */
if (file_excluded_binary && !added) {
Expand Down
6 changes: 2 additions & 4 deletions src/shared/file_op.c
Original file line number Diff line number Diff line change
Expand Up @@ -2069,11 +2069,9 @@ char **expand_win32_wildcards(const char *path) {
long unsigned errcode = GetLastError();
if (errcode == 2) {
mdebug2("No file that matches %s.", pattern);
}
else if (errcode == 3) {
} else if (errcode == 3) {
mdebug2("No folder that matches %s.", pattern);
}
else {
} else {
mdebug2("FindFirstFile failed (%lu) - '%s'\n", errcode, pattern);
}

Expand Down

0 comments on commit db44930

Please sign in to comment.