* [PATCH lttng-tools] Add test cases for options sanitizing
[not found] <20190320163313.15616-1-ylamarre@efficios.com>
@ 2019-03-20 16:33 ` Yannick Lamarre
2019-03-20 19:31 ` [PATCH lttng-tools] Fix: use strcmp instead of strncmp for full match cases Mathieu Desnoyers
1 sibling, 0 replies; 3+ messages in thread
From: Yannick Lamarre @ 2019-03-20 16:33 UTC (permalink / raw)
To: lttng-dev; +Cc: jgalar
Test cases now covers options that require full string matches which
were previously missing.
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
---
tests/regression/kernel/test_channel | 24 ++++++++++-
.../regression/tools/snapshots/test_ust_streaming | 46 +++++++++++++++++++++-
tests/regression/ust/test_event_basic | 8 +++-
tests/regression/ust/test_event_perf | 6 ++-
tests/utils/utils.sh | 26 ++++++++++++
5 files changed, 106 insertions(+), 4 deletions(-)
diff --git a/tests/regression/kernel/test_channel b/tests/regression/kernel/test_channel
index cb0fa518..f3fcee38 100755
--- a/tests/regression/kernel/test_channel
+++ b/tests/regression/kernel/test_channel
@@ -19,10 +19,31 @@ TEST_DESC="Kernel tracer - Channel configuration"
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../..
-NUM_TESTS=8
+NUM_TESTS=14
source $TESTDIR/utils/utils.sh
+function test_channel_output_opt()
+{
+ TRACE_PATH=$(mktemp -d)
+ SESSION_NAME="test_session_name"
+ CHANNEL_NAME="test_channel_name"
+ CHANNEL_NAME2="test_channel_name2"
+ create_lttng_session_ok "$SESSION_NAME" "$TRACE_PATH"
+
+ # Try to create channel with invalid output types
+ lttng_enable_kernel_channel_fail "$SESSION_NAME" "$CHANNEL_NAME" "--output=splicethenice"
+ lttng_enable_kernel_channel_fail "$SESSION_NAME" "$CHANNEL_NAME" "--output=mmap-o-spread"
+
+ # Try to create channel with valid output types
+ lttng_enable_kernel_channel_ok "$SESSION_NAME" "$CHANNEL_NAME" "--output=splice"
+ lttng_enable_kernel_channel_ok "$SESSION_NAME" "$CHANNEL_NAME2" "--output=mmap"
+
+ destroy_lttng_session_ok "$SESSION_NAME"
+
+ rm -rf "$TRACE_PATH"
+}
+
function test_channel_buffer()
{
TRACE_PATH=$(mktemp -d)
@@ -69,6 +90,7 @@ skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
test_channel_buffer
test_channel_buffer_too_large
+ test_channel_output_opt
stop_lttng_sessiond
}
diff --git a/tests/regression/tools/snapshots/test_ust_streaming b/tests/regression/tools/snapshots/test_ust_streaming
index 20d4f7f6..6a926710 100755
--- a/tests/regression/tools/snapshots/test_ust_streaming
+++ b/tests/regression/tools/snapshots/test_ust_streaming
@@ -31,7 +31,7 @@ APPS_PID=
TRACE_PATH=$(mktemp -d)
-NUM_TESTS=75
+NUM_TESTS=91
source $TESTDIR/utils/utils.sh
@@ -233,6 +233,49 @@ function test_ust_n_snapshot()
return 0
}
+# Test commandline parsing of snapshot options
+function test_ust_cmd_opt()
+{
+ diag "Test commandline parsing of snapshot options"
+ create_lttng_session_no_output $SESSION_NAME
+ enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+ start_lttng_tracing_ok $SESSION_NAME
+
+ start_test_app
+
+ snapshot_add_output $SESSION_NAME "net://localhost"
+ lttng_snapshot_record $SESSION_NAME
+
+ # Validate test
+ echo $TRACE_PATH/$HOSTNAME/snapshot-1
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-1*
+ if [ $? -ne 0 ]; then
+ stop_test_apps
+ return $?
+ fi
+
+ lttng_snapshot_del_output_by_name_fail $SESSION_NAME "snap"
+ lttng_snapshot_del_output_by_name_fail $SESSION_NAME "snapshot-100"
+ lttng_snapshot_del_output_by_name_ok $SESSION_NAME "snapshot-1"
+ snapshot_add_output $SESSION_NAME "net://localhost"
+ lttng_snapshot_record $SESSION_NAME
+
+ # Validate test with the next ID since a del output was done prior.
+ validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/snapshot-2*
+ if [ $? -ne 0 ]; then
+ stop_test_apps
+ return $?
+ fi
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+
+ stop_test_apps
+
+ return 0
+}
+
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
@@ -251,6 +294,7 @@ tests=( test_ust_default_name_with_del
test_ust_custom_name
test_ust_default_name_custom_uri
test_ust_n_snapshot
+ test_ust_cmd_opt
)
for fct_test in ${tests[@]};
diff --git a/tests/regression/ust/test_event_basic b/tests/regression/ust/test_event_basic
index 9b58cb27..c0243728 100755
--- a/tests/regression/ust/test_event_basic
+++ b/tests/regression/ust/test_event_basic
@@ -24,7 +24,7 @@ SESSION_NAME="valid_filter"
EVENT_NAME="tp:tptest"
-NUM_TESTS=25
+NUM_TESTS=28
source $TESTDIR/utils/utils.sh
@@ -43,8 +43,14 @@ function test_event_basic()
create_lttng_session_ok $SESSION_NAME2 $TRACE_PATH
enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
+
+ enable_ust_lttng_channel_fail $SESSION_NAME2 $CHAN_NAME2 "--output=splice"
+ enable_ust_lttng_channel_fail $SESSION_NAME2 $CHAN_NAME2 "--output=mmap-o-spread"
+
enable_ust_lttng_channel_ok $SESSION_NAME2 $CHAN_NAME2
+ enable_ust_lttng_channel_fail $SESSION_NAME2 $CHAN_NAME2
+
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHAN_NAME
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME2 $CHAN_NAME
enable_ust_lttng_event_ok $SESSION_NAME2 $EVENT_NAME3 $CHAN_NAME2
diff --git a/tests/regression/ust/test_event_perf b/tests/regression/ust/test_event_perf
index 4e665e65..8a1fce63 100755
--- a/tests/regression/ust/test_event_perf
+++ b/tests/regression/ust/test_event_perf
@@ -22,7 +22,7 @@ CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../..
SESSION_NAME="perf_counters"
EVENT_NAME="tp:tptest"
-NUM_TESTS=24
+NUM_TESTS=28
NR_ITER=1
NR_USEC_WAIT=1
TESTAPP_PATH="$TESTDIR/utils/testapp"
@@ -55,6 +55,10 @@ function test_parsing_raw()
enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
add_context_ust_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test"
+ add_context_ust_fail $SESSION_NAME $CHAN_NAME "perform:thread:raw:r0110:test"
+ add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:threadish:raw:r0110:test"
+ add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:cpush:raw:r0110:test"
+ add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:rawesome:r0110:test"
add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:rZZZ:test"
add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
add_context_ust_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 94b3a3c4..cba38b93 100644
--- a/tests/utils/utils.sh
+++ b/tests/utils/utils.sh
@@ -1282,6 +1282,32 @@ function lttng_snapshot_del_output_fail ()
lttng_snapshot_del_output 1 "$@"
}
+function lttng_snapshot_del_output_by_name ()
+{
+ local expected_to_fail=$1
+ local sess_name=$2
+ local name=$3
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN snapshot del-output -s $sess_name $name 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+ ret=$?
+ if [[ $expected_to_fail -eq "1" ]]; then
+ test "$ret" -ne "0"
+ ok $? "Deleted snapshot output name $name failed as expected"
+ else
+ ok $ret "Deleted snapshot output name $name"
+ fi
+}
+
+function lttng_snapshot_del_output_by_name_ok ()
+{
+ lttng_snapshot_del_output_by_name 0 "$@"
+}
+
+function lttng_snapshot_del_output_by_name_fail ()
+{
+ lttng_snapshot_del_output_by_name 1 "$@"
+}
+
function lttng_snapshot_record ()
{
local sess_name=$1
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH lttng-tools] Fix: use strcmp instead of strncmp for full match cases
[not found] <20190320163313.15616-1-ylamarre@efficios.com>
2019-03-20 16:33 ` [PATCH lttng-tools] Add test cases for options sanitizing Yannick Lamarre
@ 2019-03-20 19:31 ` Mathieu Desnoyers
1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Desnoyers @ 2019-03-20 19:31 UTC (permalink / raw)
To: Yannick Lamarre; +Cc: lttng-dev, Jeremie Galarneau
----- On Mar 20, 2019, at 12:33 PM, Yannick Lamarre ylamarre@efficios.com wrote:
> Except for a single case where the compared string is not ended with
> '\0', strncmp was replaced by strcmp in cases where a full string match
> was required. The exception was fixed with a length comparison prior
> the strncmp call.
I'm worried about the security implications associated with turning
strncmp into strcmp in situations where the input could be controlled
by an attacker.
This should come with a more thorough explanation detailing why this
change is needed, and how comes it does not introduce a security risk,
IOW, what is the scheme used to do input validation before using strcmp
on that input ?
Thanks,
MAthieu
>
> Fixes: #987
> Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
> ---
> src/bin/lttng-sessiond/agent.c | 3 +--
> src/bin/lttng-sessiond/cmd.c | 2 +-
> src/bin/lttng-sessiond/snapshot.c | 2 +-
> src/bin/lttng-sessiond/ust-registry.c | 2 +-
> src/bin/lttng/commands/add_context.c | 8 ++++----
> src/bin/lttng/commands/create.c | 4 +---
> src/bin/lttng/commands/enable_channels.c | 4 ++--
> src/common/lttng-elf.c | 1 +
> src/common/testpoint/testpoint.c | 4 ++--
> 9 files changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c
> index 3b8acd2a..af65fa9c 100644
> --- a/src/bin/lttng-sessiond/agent.c
> +++ b/src/bin/lttng-sessiond/agent.c
> @@ -149,8 +149,7 @@ static int ht_match_event(struct cds_lfht_node *node,
> }
>
> if (event->filter_expression) {
> - if (strncmp(event->filter_expression, key->filter_expression,
> - strlen(event->filter_expression)) != 0) {
> + if (strcmp(event->filter_expression, key->filter_expression) != 0) {
> goto no_match;
> }
> }
> diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
> index d91869fa..52591383 100644
> --- a/src/bin/lttng-sessiond/cmd.c
> +++ b/src/bin/lttng-sessiond/cmd.c
> @@ -2310,7 +2310,7 @@ static int _cmd_enable_event(struct ltt_session *session,
> }
>
> /* The wild card * means that everything should be enabled. */
> - if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
> + if (!strcmp(event->name, "*")) {
> ret = event_agent_enable_all(usess, agt, event, filter,
> filter_expression);
> } else {
> diff --git a/src/bin/lttng-sessiond/snapshot.c
> b/src/bin/lttng-sessiond/snapshot.c
> index 447806bf..db7cfe77 100644
> --- a/src/bin/lttng-sessiond/snapshot.c
> +++ b/src/bin/lttng-sessiond/snapshot.c
> @@ -251,7 +251,7 @@ struct snapshot_output *snapshot_find_output_by_name(const
> char *name,
>
> cds_lfht_for_each_entry(snapshot->output_ht->ht, &iter.iter, output,
> node.node) {
> - if (!strncmp(output->name, name, strlen(name))) {
> + if (!strcmp(output->name, name)) {
> return output;
> }
> }
> diff --git a/src/bin/lttng-sessiond/ust-registry.c
> b/src/bin/lttng-sessiond/ust-registry.c
> index a8db79ea..8045075a 100644
> --- a/src/bin/lttng-sessiond/ust-registry.c
> +++ b/src/bin/lttng-sessiond/ust-registry.c
> @@ -48,7 +48,7 @@ static int ht_match_event(struct cds_lfht_node *node, const
> void *_key)
> key = _key;
>
> /* It has to be a perfect match. First, compare the event names. */
> - if (strncmp(event->name, key->name, sizeof(event->name))) {
> + if (strcmp(event->name, key->name)) {
> goto no_match;
> }
>
> diff --git a/src/bin/lttng/commands/add_context.c
> b/src/bin/lttng/commands/add_context.c
> index 7aef4d50..3fd1ebd0 100644
> --- a/src/bin/lttng/commands/add_context.c
> +++ b/src/bin/lttng/commands/add_context.c
> @@ -885,15 +885,15 @@ int find_ctx_type_perf_raw(const char *ctx, struct
> ctx_type *type)
> cur_list = NULL;
> switch (field_pos) {
> case 0:
> - if (strncmp(next, "perf", 4) != 0) {
> + if (strcmp(next, "perf") != 0) {
> ret = -1;
> goto end;
> }
> break;
> case 1:
> - if (strncmp(next, "cpu", 3) == 0) {
> + if (strcmp(next, "cpu") == 0) {
> type->opt->ctx_type = CONTEXT_PERF_CPU_COUNTER;
> - } else if (strncmp(next, "thread", 4) == 0) {
> + } else if (strcmp(next, "thread") == 0) {
> type->opt->ctx_type = CONTEXT_PERF_THREAD_COUNTER;
> } else {
> ret = -1;
> @@ -901,7 +901,7 @@ int find_ctx_type_perf_raw(const char *ctx, struct ctx_type
> *type)
> }
> break;
> case 2:
> - if (strncmp(next, "raw", 3) != 0) {
> + if (strcmp(next, "raw") != 0) {
> ret = -1;
> goto end;
> }
> diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c
> index d2741c37..aea02dd3 100644
> --- a/src/bin/lttng/commands/create.c
> +++ b/src/bin/lttng/commands/create.c
> @@ -264,9 +264,7 @@ static int create_session(void)
> */
> if ((strncmp(opt_session_name, DEFAULT_SESSION_NAME "-",
> strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
> - (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
> - strlen(DEFAULT_SESSION_NAME)) == 0 &&
> - strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME))) {
> + (strcmp(opt_session_name, DEFAULT_SESSION_NAME) == 0)) {
> ERR("%s is a reserved keyword for default session(s)",
> DEFAULT_SESSION_NAME);
> ret = CMD_ERROR;
> diff --git a/src/bin/lttng/commands/enable_channels.c
> b/src/bin/lttng/commands/enable_channels.c
> index b4e2942c..52d18bcc 100644
> --- a/src/bin/lttng/commands/enable_channels.c
> +++ b/src/bin/lttng/commands/enable_channels.c
> @@ -210,9 +210,9 @@ static int enable_channel(char *session_name)
>
> /* Setting channel output */
> if (opt_output) {
> - if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) {
> + if (!strcmp(output_mmap, opt_output)) {
> chan_opts.attr.output = LTTNG_EVENT_MMAP;
> - } else if (!strncmp(output_splice, opt_output, strlen(output_splice))) {
> + } else if (!strcmp(output_splice, opt_output)) {
> chan_opts.attr.output = LTTNG_EVENT_SPLICE;
> } else {
> ERR("Unknown output type %s. Possible values are: %s, %s\n",
> diff --git a/src/common/lttng-elf.c b/src/common/lttng-elf.c
> index cd10632c..2487e8bf 100644
> --- a/src/common/lttng-elf.c
> +++ b/src/common/lttng-elf.c
> @@ -975,6 +975,7 @@ int lttng_elf_get_sdt_probe_offsets(int fd, const char
> *provider_name,
> * and go to the next 4 byte alignement.
> */
> if (note_type != NOTE_STAPSDT_TYPE ||
> + name_size != strlen(NOTE_STAPSDT_NAME) ||
> strncmp(curr_data_ptr, NOTE_STAPSDT_NAME, name_size) != 0) {
> continue;
> }
> diff --git a/src/common/testpoint/testpoint.c b/src/common/testpoint/testpoint.c
> index 8ce5b9d2..d94772bb 100644
> --- a/src/common/testpoint/testpoint.c
> +++ b/src/common/testpoint/testpoint.c
> @@ -20,7 +20,7 @@
> #define _LGPL_SOURCE
> #include <dlfcn.h> /* for dlsym */
> #include <stdlib.h> /* for getenv */
> -#include <string.h> /* for strncmp */
> +#include <string.h> /* for strcmp */
>
> #include "testpoint.h"
>
> @@ -39,7 +39,7 @@ static void __attribute__((constructor))
> lttng_testpoint_check(void)
>
> testpoint_env_val = getenv(lttng_testpoint_env_var);
> if (testpoint_env_val != NULL
> - && (strncmp(testpoint_env_val, "1", 1) == 0)) {
> + && strcmp(testpoint_env_val, "1") == 0) {
> lttng_testpoint_activated = 1;
> }
> }
> --
> 2.11.0
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH lttng-tools] Fix: use strcmp instead of strncmp for full match cases
@ 2019-03-20 16:33 Yannick Lamarre
0 siblings, 0 replies; 3+ messages in thread
From: Yannick Lamarre @ 2019-03-20 16:33 UTC (permalink / raw)
To: lttng-dev; +Cc: jgalar
Except for a single case where the compared string is not ended with
'\0', strncmp was replaced by strcmp in cases where a full string match
was required. The exception was fixed with a length comparison prior
the strncmp call.
Fixes: #987
Signed-off-by: Yannick Lamarre <ylamarre@efficios.com>
---
src/bin/lttng-sessiond/agent.c | 3 +--
src/bin/lttng-sessiond/cmd.c | 2 +-
src/bin/lttng-sessiond/snapshot.c | 2 +-
src/bin/lttng-sessiond/ust-registry.c | 2 +-
src/bin/lttng/commands/add_context.c | 8 ++++----
src/bin/lttng/commands/create.c | 4 +---
src/bin/lttng/commands/enable_channels.c | 4 ++--
src/common/lttng-elf.c | 1 +
src/common/testpoint/testpoint.c | 4 ++--
9 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/bin/lttng-sessiond/agent.c b/src/bin/lttng-sessiond/agent.c
index 3b8acd2a..af65fa9c 100644
--- a/src/bin/lttng-sessiond/agent.c
+++ b/src/bin/lttng-sessiond/agent.c
@@ -149,8 +149,7 @@ static int ht_match_event(struct cds_lfht_node *node,
}
if (event->filter_expression) {
- if (strncmp(event->filter_expression, key->filter_expression,
- strlen(event->filter_expression)) != 0) {
+ if (strcmp(event->filter_expression, key->filter_expression) != 0) {
goto no_match;
}
}
diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c
index d91869fa..52591383 100644
--- a/src/bin/lttng-sessiond/cmd.c
+++ b/src/bin/lttng-sessiond/cmd.c
@@ -2310,7 +2310,7 @@ static int _cmd_enable_event(struct ltt_session *session,
}
/* The wild card * means that everything should be enabled. */
- if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
+ if (!strcmp(event->name, "*")) {
ret = event_agent_enable_all(usess, agt, event, filter,
filter_expression);
} else {
diff --git a/src/bin/lttng-sessiond/snapshot.c b/src/bin/lttng-sessiond/snapshot.c
index 447806bf..db7cfe77 100644
--- a/src/bin/lttng-sessiond/snapshot.c
+++ b/src/bin/lttng-sessiond/snapshot.c
@@ -251,7 +251,7 @@ struct snapshot_output *snapshot_find_output_by_name(const char *name,
cds_lfht_for_each_entry(snapshot->output_ht->ht, &iter.iter, output,
node.node) {
- if (!strncmp(output->name, name, strlen(name))) {
+ if (!strcmp(output->name, name)) {
return output;
}
}
diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c
index a8db79ea..8045075a 100644
--- a/src/bin/lttng-sessiond/ust-registry.c
+++ b/src/bin/lttng-sessiond/ust-registry.c
@@ -48,7 +48,7 @@ static int ht_match_event(struct cds_lfht_node *node, const void *_key)
key = _key;
/* It has to be a perfect match. First, compare the event names. */
- if (strncmp(event->name, key->name, sizeof(event->name))) {
+ if (strcmp(event->name, key->name)) {
goto no_match;
}
diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c
index 7aef4d50..3fd1ebd0 100644
--- a/src/bin/lttng/commands/add_context.c
+++ b/src/bin/lttng/commands/add_context.c
@@ -885,15 +885,15 @@ int find_ctx_type_perf_raw(const char *ctx, struct ctx_type *type)
cur_list = NULL;
switch (field_pos) {
case 0:
- if (strncmp(next, "perf", 4) != 0) {
+ if (strcmp(next, "perf") != 0) {
ret = -1;
goto end;
}
break;
case 1:
- if (strncmp(next, "cpu", 3) == 0) {
+ if (strcmp(next, "cpu") == 0) {
type->opt->ctx_type = CONTEXT_PERF_CPU_COUNTER;
- } else if (strncmp(next, "thread", 4) == 0) {
+ } else if (strcmp(next, "thread") == 0) {
type->opt->ctx_type = CONTEXT_PERF_THREAD_COUNTER;
} else {
ret = -1;
@@ -901,7 +901,7 @@ int find_ctx_type_perf_raw(const char *ctx, struct ctx_type *type)
}
break;
case 2:
- if (strncmp(next, "raw", 3) != 0) {
+ if (strcmp(next, "raw") != 0) {
ret = -1;
goto end;
}
diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c
index d2741c37..aea02dd3 100644
--- a/src/bin/lttng/commands/create.c
+++ b/src/bin/lttng/commands/create.c
@@ -264,9 +264,7 @@ static int create_session(void)
*/
if ((strncmp(opt_session_name, DEFAULT_SESSION_NAME "-",
strlen(DEFAULT_SESSION_NAME) + 1) == 0) ||
- (strncmp(opt_session_name, DEFAULT_SESSION_NAME,
- strlen(DEFAULT_SESSION_NAME)) == 0 &&
- strlen(opt_session_name) == strlen(DEFAULT_SESSION_NAME))) {
+ (strcmp(opt_session_name, DEFAULT_SESSION_NAME) == 0)) {
ERR("%s is a reserved keyword for default session(s)",
DEFAULT_SESSION_NAME);
ret = CMD_ERROR;
diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c
index b4e2942c..52d18bcc 100644
--- a/src/bin/lttng/commands/enable_channels.c
+++ b/src/bin/lttng/commands/enable_channels.c
@@ -210,9 +210,9 @@ static int enable_channel(char *session_name)
/* Setting channel output */
if (opt_output) {
- if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) {
+ if (!strcmp(output_mmap, opt_output)) {
chan_opts.attr.output = LTTNG_EVENT_MMAP;
- } else if (!strncmp(output_splice, opt_output, strlen(output_splice))) {
+ } else if (!strcmp(output_splice, opt_output)) {
chan_opts.attr.output = LTTNG_EVENT_SPLICE;
} else {
ERR("Unknown output type %s. Possible values are: %s, %s\n",
diff --git a/src/common/lttng-elf.c b/src/common/lttng-elf.c
index cd10632c..2487e8bf 100644
--- a/src/common/lttng-elf.c
+++ b/src/common/lttng-elf.c
@@ -975,6 +975,7 @@ int lttng_elf_get_sdt_probe_offsets(int fd, const char *provider_name,
* and go to the next 4 byte alignement.
*/
if (note_type != NOTE_STAPSDT_TYPE ||
+ name_size != strlen(NOTE_STAPSDT_NAME) ||
strncmp(curr_data_ptr, NOTE_STAPSDT_NAME, name_size) != 0) {
continue;
}
diff --git a/src/common/testpoint/testpoint.c b/src/common/testpoint/testpoint.c
index 8ce5b9d2..d94772bb 100644
--- a/src/common/testpoint/testpoint.c
+++ b/src/common/testpoint/testpoint.c
@@ -20,7 +20,7 @@
#define _LGPL_SOURCE
#include <dlfcn.h> /* for dlsym */
#include <stdlib.h> /* for getenv */
-#include <string.h> /* for strncmp */
+#include <string.h> /* for strcmp */
#include "testpoint.h"
@@ -39,7 +39,7 @@ static void __attribute__((constructor)) lttng_testpoint_check(void)
testpoint_env_val = getenv(lttng_testpoint_env_var);
if (testpoint_env_val != NULL
- && (strncmp(testpoint_env_val, "1", 1) == 0)) {
+ && strcmp(testpoint_env_val, "1") == 0) {
lttng_testpoint_activated = 1;
}
}
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-20 19:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20190320163313.15616-1-ylamarre@efficios.com>
2019-03-20 16:33 ` [PATCH lttng-tools] Add test cases for options sanitizing Yannick Lamarre
2019-03-20 19:31 ` [PATCH lttng-tools] Fix: use strcmp instead of strncmp for full match cases Mathieu Desnoyers
2019-03-20 16:33 Yannick Lamarre
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.