From: Yannick Lamarre Date: Tue, 26 Mar 2019 19:53:06 +0000 (-0400) Subject: Fix: Properly sanitize input parameter X-Git-Tag: v2.10.7~14 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=cd0a192bca259357d60797584d6ef7978186ac10;p=lttng-tools.git Fix: Properly sanitize input parameter The lttng client uses the sizeof the containing buffer, defined as LTTNG_SYMBOL_NAME_LEN, for input string sanitation instead of libc defined macro NAME_MAX. lttng-enable_channel improperly verified user input and wrongly discarded valid input in case NAME_MAX was less than the sizeof the containing buffer for the channel's name. This patch also fixes potential buffer overflow caused by an improperly bounded strcpy in the case where NAME_MAX would have been greater than LTTNG_SYMBOL_NAME_LEN. Signed-off-by: Yannick Lamarre Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 9c84d0263..856fea46f 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -244,7 +244,7 @@ static int enable_channel(char *session_name) void *extended_ptr; /* Validate channel name's length */ - if (strlen(channel_name) >= NAME_MAX) { + if (strlen(channel_name) >= sizeof(chan_opts.name)) { ERR("Channel name is too long (max. %zu characters)", sizeof(chan_opts.name) - 1); error = 1;