From 71e147d0f7a3e161f0814376955e57b2e8db70c8 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 15 Jun 2016 17:18:03 -0400 Subject: [PATCH] Fix: sessiond ht_match_event() check if filter is NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It looks like an agent event's filter expression is NULL when it's created with -a, for example: lttng enable-event -j -a Since there's no check for this in ht_match_event(), strlen() makes the session daemon segfault with this scenario: lttng create lttng enable-event -j -a lttng disable-event -j -a Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/agent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c index 8e1ef0849..7cbbbdee0 100644 --- a/src/bin/lttng-sessiond/agent.c +++ b/src/bin/lttng-sessiond/agent.c @@ -143,11 +143,18 @@ static int ht_match_event(struct cds_lfht_node *node, } /* Filter expression */ - if (strncmp(event->filter_expression, key->filter_expression, - strlen(event->filter_expression)) != 0) { + if (!!event->filter_expression ^ !!key->filter_expression) { + /* One has a filter expression, the other does not */ goto no_match; } + if (event->filter_expression) { + if (strncmp(event->filter_expression, key->filter_expression, + strlen(event->filter_expression)) != 0) { + goto no_match; + } + } + return 1; no_match: -- 2.34.1