Don't attempt to load the rule files if the rule-files configuration

node is not a sequence.  Instead log a warning as this is usually
a configuration error.
pull/1365/head
Jason Ish 12 years ago committed by Victor Julien
parent a243a42bdf
commit 6ed246c041

@ -1414,18 +1414,26 @@ end:
int
ConfNodeIsSequenceTest(void)
{
int retval = 0;
ConfNode *node = ConfNodeNew();
if (node == NULL) {
return 0;
goto end;
}
if (ConfNodeIsSequence(node)) {
return 0;
goto end;
}
node->is_seq = 1;
if (!ConfNodeIsSequence(node)) {
return 0;
goto end;
}
return 1;
retval = 1;
end:
if (node != NULL) {
ConfNodeFree(node);
}
return retval;
}
void

@ -405,22 +405,30 @@ int SigLoadSignatures(DetectEngineCtx *de_ctx, char *sig_file, int sig_file_excl
if (!(sig_file != NULL && sig_file_exclusive == TRUE)) {
rule_files = ConfGetNode("rule-files");
if (rule_files != NULL) {
TAILQ_FOREACH(file, &rule_files->head, next) {
sfile = DetectLoadCompleteSigPath(file->val);
SCLogDebug("Loading rule file: %s", sfile);
cntf++;
r = DetectLoadSigFile(de_ctx, sfile, &goodsigs, &badsigs);
if (r < 0) {
badfiles++;
}
if (goodsigs == 0) {
SCLogWarning(SC_ERR_NO_RULES, "No rules loaded from %s", sfile);
}
SCFree(sfile);
if (!ConfNodeIsSequence(rule_files)) {
SCLogWarning(SC_ERR_INVALID_ARGUMENT,
"Invalid rule-files configuration section: "
"expected a list of filenames.");
}
else {
TAILQ_FOREACH(file, &rule_files->head, next) {
sfile = DetectLoadCompleteSigPath(file->val);
SCLogDebug("Loading rule file: %s", sfile);
cntf++;
r = DetectLoadSigFile(de_ctx, sfile, &goodsigs, &badsigs);
if (r < 0) {
badfiles++;
}
if (goodsigs == 0) {
SCLogWarning(SC_ERR_NO_RULES,
"No rules loaded from %s", sfile);
}
SCFree(sfile);
goodtotal += goodsigs;
badtotal += badsigs;
goodtotal += goodsigs;
badtotal += badsigs;
}
}
}
}

Loading…
Cancel
Save