-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix lf location array from unknown syslog #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ddpbsd
merged 3 commits into
ossec:master
from
atomicturtle:fix-lf-location-array-from-unknow-syslog
Jan 2, 2019
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,15 +251,18 @@ int W_isRootcheck(cJSON *root, int nested){ | |
// ** TODO ** Regex instead str_cut | ||
void W_JSON_ParseHostname(cJSON *root, char *hostname){ | ||
if(hostname[0] == '('){ | ||
char *e; | ||
char string[strlen(hostname) + 1]; | ||
strcpy(string,hostname); | ||
char *search; | ||
char string[MAX_STRING]; | ||
strncpy(string,hostname,MAX_STRING); | ||
int index; | ||
e = strchr(string, ')'); | ||
index = (int)(e - string); | ||
str_cut(string, index, -1); | ||
str_cut(string, 0, 1); | ||
cJSON_AddStringToObject(root, "hostname", string); | ||
search = strchr(string, ')'); | ||
if(search){ | ||
index = (int)(search - string); | ||
str_cut(string, index, -1); | ||
str_cut(string, 0, 1); | ||
cJSON_AddStringToObject(root, "hostname", string); | ||
} | ||
|
||
}else{ | ||
cJSON_AddStringToObject(root, "hostname", hostname); | ||
} | ||
|
@@ -276,36 +279,41 @@ void W_JSON_ParseHostname(cJSON *root, char *hostname){ | |
// ** TODO ** Regex instead str_cut | ||
void W_JSON_ParseAgentIP(cJSON *root, const Eventinfo *lf){ | ||
if(lf->hostname[0] == '('){ | ||
char *e; | ||
char string[strlen(lf->hostname) + 1]; | ||
strcpy(string,lf->hostname); | ||
char *search; | ||
char string[MAX_STRING]; | ||
strncpy(string,lf->hostname,MAX_STRING); | ||
ddpbsd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int index; | ||
e = strchr(string, ')'); | ||
index = (int)(e - string); | ||
str_cut(string, 0, index); | ||
str_cut(string, 0, 2); | ||
e = strchr(string, '-'); | ||
index = (int)(e - string); | ||
str_cut(string, index, -1); | ||
cJSON_AddStringToObject(root, "agentip", string); | ||
search = strchr(string, ')'); | ||
if(search){ | ||
index = (int)(search - string); | ||
str_cut(string, 0, index); | ||
str_cut(string, 0, 2); | ||
search = strchr(string, '-'); | ||
index = (int)(search - string); | ||
str_cut(string, index, -1); | ||
cJSON_AddStringToObject(root, "agentip", string); | ||
} | ||
} | ||
|
||
} | ||
// The file location usually comes with more information about the alert (like hostname or ip) we will extract just the "/var/folder/file.log". | ||
void W_JSON_ParseLocation(cJSON *root, const Eventinfo *lf, int archives){ | ||
if(lf->location[0] == '('){ | ||
char *e; | ||
char string[strlen(lf->location)]; | ||
strcpy(string,lf->location); | ||
char *search; | ||
char string[MAX_STRING]; | ||
strncpy(string,lf->location,MAX_STRING); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another sloppy strncpy |
||
int index; | ||
e = strchr(string, '>'); | ||
index = (int)(e - string); | ||
str_cut(string, 0, index); | ||
str_cut(string, 0, 1); | ||
if(archives == 1) | ||
cJSON_AddStringToObject(root, "location_desc", string); | ||
else | ||
cJSON_AddStringToObject(root, "location", string); | ||
search = strchr(string, '>'); | ||
if(search){ | ||
index = (int)(search - string); | ||
str_cut(string, 0, index); | ||
str_cut(string, 0, 1); | ||
|
||
if(archives == 1) | ||
cJSON_AddStringToObject(root, "location_desc", string); | ||
else | ||
cJSON_AddStringToObject(root, "location", string); | ||
} | ||
}else{ | ||
if(archives == 1) | ||
cJSON_AddStringToObject(root, "location_desc", lf->location); | ||
|
@@ -382,9 +390,3 @@ void trim(char * s) { | |
|
||
memmove(s, p, l + 1); | ||
} | ||
void removeChar( char * string, char letter ) { | ||
unsigned int i; | ||
for(i = 0; i < strlen( string ); i++ ) | ||
if( string[i] == letter ) | ||
strcpy( string + i, string + i + 1 ); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.