Skip to content
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

fix: Allow inline comments in clamd.conf #1308

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading