Browse files

patterndb: Fix a NULL dereference in certain cases

In patterndb, all of the context-* properties are optional, yet, in
certain cases where they were only partially set (eg, context-id and
context-time set, but context-scope not), running an action ended up
with syslog-ng trying to dereference a NULL pointer.

This patch corrects that mistake, by teaching pdb_rule_run_actions()
to only dereference the context if it is non-NULL. The bulk of the
function handled the case well, just not the initial condition that
governs the core of the function.

Reported-by: Imre Lazar <>
Signed-off-by: Gergely Nagy <>
  • Loading branch information...
1 parent 96001b3 commit b67ee8aa6335318146b79acdef45c90f6aecbc04 @algernon algernon committed Jun 29, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 modules/dbparser/patterndb.c
4 modules/dbparser/patterndb.c
@@ -543,7 +543,9 @@ pdb_rule_run_actions(PDBRule *self, gint trigger, PatternDB *db, PDBContext *con
LogMessage *genmsg;
- if ((!action->condition || filter_expr_eval_with_context(action->condition, (LogMessage **) context->messages->pdata, context->messages->len)) && pdb_rule_check_rate_limit(self, db, action, msg, buffer))
+ if ((!action->condition ||
+ (!context || filter_expr_eval_with_context(action->condition, (LogMessage **) context->messages->pdata, context->messages->len))) &&
+ pdb_rule_check_rate_limit(self, db, action, msg, buffer))
switch (action->content_type)

0 comments on commit b67ee8a

Please sign in to comment.