Skip to content

Commit

Permalink
fix: Allow inline comments in clamd.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
userwiths committed Jul 11, 2024
1 parent 1d30588 commit ef7d483
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions common/optparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@

#define MAXCMDOPTS 150

#define MATCH_NUMBER "^[0-9]+$"
#define MATCH_SIZE "^[0-9]+[KMG]?$"
#define MATCH_BOOL "^(yes|true|1|no|false|0)$"
#define MATCH_NUMBER "^[0-9]+((( +)?#(.*))?)$"
#define MATCH_SIZE "^[0-9]+[KMG]?(( +)?#(.*))?$"
#define MATCH_BOOL "^(yes|true|1|no|false|0)(( +)?#(.*))?$"

#define FLAG_MULTIPLE 1 /* option can be used multiple times */
#define FLAG_REQUIRED 2 /* arg is required, even if there's a default value */
Expand Down Expand Up @@ -931,6 +931,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
regex_t regex;
long long numarg, lnumarg, lnumlimit;
int regflags = REG_EXTENDED | REG_NOSUB;
const char* inlinecomment = NULL;

#ifdef _WIN32
if (!is_initialized) {
Expand Down Expand Up @@ -1187,6 +1188,10 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
}

numarg = -1;
inlinecomment = strchr(arg, '#');
if (inlinecomment != NULL) {
arg = strtok(arg, "#");
}
switch (optentry->argtype) {
case CLOPT_TYPE_STRING:
if (!arg)
Expand Down

0 comments on commit ef7d483

Please sign in to comment.