Fix: lttng: initialize variable in run_command_string
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 30 Nov 2021 03:15:53 +0000 (22:15 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 21 Jan 2022 22:58:05 +0000 (17:58 -0500)
commit0b8afa0338a777bd61165a7699a12b8bd8ebe913
treed5c898de01251a578575c7a4f58fe921bc25d9ff
parent4828ba4c60cb159930c2038c87d540c7ab867ff7
Fix: lttng: initialize variable in run_command_string

I got some crashes when using `lttng track` and hitting some error
paths.  The tracker_handle variable is run_command_string is passed to
lttng_process_attr_tracker_handle_destroy uninitialized if
lttng_session_get_tracker_handle fails.

    $ valgrind lttng track --kernel --pid 569878
    ==634572== Memcheck, a memory error detector
    ==634572== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==634572== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
    ==634572== Command: lttng track --kernel --pid 569878
    ==634572==
    Error: Unknown error
    ==634572== Conditional jump or move depends on uninitialised value(s)
    ==634572==    at 0x4875007: lttng_process_attr_tracker_handle_destroy (tracker.cpp:25)
    ==634572==    by 0x13AC55: run_command_string(cmd_type, char const*, lttng_domain_type, lttng_process_attr, char const*, mi_writer*) (track-untrack.cpp:485)
    ==634572==    by 0x13ADA5: run_command(cmd_type, char const*, process_attr_command_args const*, mi_writer*) (track-untrack.cpp:535)
    ==634572==    by 0x13B472: cmd_track_untrack(cmd_type, int, char const**, char const*) (track-untrack.cpp:740)
    ==634572==    by 0x13B5D9: cmd_track(int, char const**) (track-untrack.cpp:805)
    ==634572==    by 0x14C598: handle_command(int, char**) (lttng.cpp:237)
    ==634572==    by 0x14CCE9: parse_args(int, char**) (lttng.cpp:426)
    ==634572==    by 0x14CE65: main (lttng.cpp:475)

Fix it by initializing it to NULL.

Change-Id: Id2693e75c3c5c83cef58db3109973d7ab679b859
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/track-untrack.c
This page took 0.024873 seconds and 4 git commands to generate.