From: Mathieu Desnoyers Date: Wed, 25 Jan 2012 14:37:39 +0000 (-0500) Subject: Fix sessiond needed checks X-Git-Tag: v2.0-pre19~50 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ba2926efa2f16966165993d654f99574c3624ef4;p=lttng-tools.git Fix sessiond needed checks - strncmp should compare up to and _include_ the \0 (was off by one). Instead of 2 for "-h", it should be 3. Use "sizeof("-h")" instead of hardcoding 3. - strncmp logic was reversed for the --list-options check. Signed-off-by: Mathieu Desnoyers --- diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index a8cc2e72f..57927d4f3 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -387,9 +387,9 @@ static int check_args_no_sessiond(int argc, char **argv) int i; for (i = 0; i < argc; i++) { - if ((strncmp(argv[i], "-h", 2) == 0) || - strncmp(argv[i], "--h", 3) == 0 || - strncmp(argv[i], "--list-options", 14)) { + if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) || + strncmp(argv[i], "--h", sizeof("--h")) == 0 || + strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) { return 1; } }