]> git.lttng.org Git - lttng-tools.git/commitdiff
Fix: sessiond: leak of filter_expression, bytecode, and exclusion
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Nov 2024 14:56:53 +0000 (14:56 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 26 Nov 2024 17:05:50 +0000 (17:05 +0000)
The filter_expression, bytecode, and exclusion arguments are leaked
whenever a client omits the transmission of an event-rule as part of an
enable-event command (a protocol error).

Ensure the three arguments are automatically managed using smart
pointers before performing the protocol consistency check.

Change-Id: I4c4f1d5d7b6acdd215ef34e1fc8f2c4bc81a674a
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.cpp

index 3906b30c6fb17cc1f39052b12e925946253e72f4..425b552f49ab1ad9699fdb136b2886a163538c63 100644 (file)
@@ -2389,6 +2389,13 @@ static lttng_error_code _cmd_enable_event(ltt_session::locked_ref& locked_sessio
                                          bool internal_event,
                                          lttng::event_rule_uptr event_rule)
 {
+       auto filter_expression =
+               lttng::make_unique_wrapper<char, lttng::memory::free>(raw_filter_expression);
+       auto bytecode =
+               lttng::make_unique_wrapper<lttng_bytecode, lttng::memory::free>(raw_bytecode);
+       auto exclusion = lttng::make_unique_wrapper<lttng_event_exclusion, lttng::memory::free>(
+               raw_exclusion);
+
        if (!event_rule) {
                return LTTNG_ERR_INVALID_PROTOCOL;
        }
@@ -2397,13 +2404,6 @@ static lttng_error_code _cmd_enable_event(ltt_session::locked_ref& locked_sessio
        struct lttng_channel *attr = nullptr;
        ltt_session& session = *locked_session;
 
-       auto filter_expression =
-               lttng::make_unique_wrapper<char, lttng::memory::free>(raw_filter_expression);
-       auto bytecode =
-               lttng::make_unique_wrapper<lttng_bytecode, lttng::memory::free>(raw_bytecode);
-       auto exclusion = lttng::make_unique_wrapper<lttng_event_exclusion, lttng::memory::free>(
-               raw_exclusion);
-
        LTTNG_ASSERT(event);
        LTTNG_ASSERT(channel_name);
 
This page took 0.031539 seconds and 4 git commands to generate.