mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
Fix NULL-dereference crash with some command line options
It is possible to crash freshclam and probably other programs like this: ``` freshclam --datadir /any/path ``` CLAM-2860
This commit is contained in:
parent
c11ac06e0e
commit
d14bbe2fda
1 changed files with 11 additions and 9 deletions
|
@ -1253,15 +1253,17 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
|
|||
}
|
||||
}
|
||||
|
||||
/* Find and remove inline comments. */
|
||||
numarg = -1;
|
||||
inlinecomment = strchr(arg, '#');
|
||||
if (inlinecomment != NULL) {
|
||||
/* Found a '#', indicating an inline comment. Strip it off along with any leading spaces or tabs. */
|
||||
arg = strtok(arg, "#");
|
||||
trim_comment = arg + strlen(arg) - 1;
|
||||
while (trim_comment >= arg && (*trim_comment == ' ' || *trim_comment == '\t')) {
|
||||
*(trim_comment--) = '\0';
|
||||
if (NULL != arg) {
|
||||
/* Find and remove inline comments. */
|
||||
numarg = -1;
|
||||
inlinecomment = strchr(arg, '#');
|
||||
if (inlinecomment != NULL) {
|
||||
/* Found a '#', indicating an inline comment. Strip it off along with any leading spaces or tabs. */
|
||||
arg = strtok(arg, "#");
|
||||
trim_comment = arg + strlen(arg) - 1;
|
||||
while (trim_comment >= arg && (*trim_comment == ' ' || *trim_comment == '\t')) {
|
||||
*(trim_comment--) = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue