Fix: sessiond: incorrect use of exclusions array leads to crash
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.cpp
index 79cb6fed89398e00833f2ea27620090eba09e81e..ef4383ff25a67262c2f6d5157422a916d94a9147 100644 (file)
@@ -484,18 +484,28 @@ static enum lttng_error_code list_lttng_ust_global_events(char *channel_name,
                        tmp_event->exclusion = 1;
                }
 
+               std::vector<const char *> exclusion_names;
+               if (uevent->exclusion) {
+                       for (int i = 0; i < uevent->exclusion->count; i++) {
+                               exclusion_names.emplace_back(
+                                       LTTNG_EVENT_EXCLUSION_NAME_AT(uevent->exclusion, i));
+                       }
+               }
+
                /*
                 * We do not care about the filter bytecode and the fd from the
                 * userspace_probe_location.
                 */
-               ret = lttng_event_serialize(tmp_event,
-                                           uevent->exclusion ? uevent->exclusion->count : 0,
-                                           uevent->exclusion ? (char **) uevent->exclusion->names :
-                                                               nullptr,
-                                           uevent->filter_expression,
-                                           0,
-                                           nullptr,
-                                           reply_payload);
+               ret = lttng_event_serialize(
+                       tmp_event,
+                       exclusion_names.size(),
+                       exclusion_names.size() ?
+                               exclusion_names.data() :
+                               nullptr,
+                       uevent->filter_expression,
+                       0,
+                       nullptr,
+                       reply_payload);
                lttng_event_destroy(tmp_event);
                if (ret) {
                        ret_code = LTTNG_ERR_FATAL;
This page took 0.023991 seconds and 4 git commands to generate.