From ba2926efa2f16966165993d654f99574c3624ef4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 25 Jan 2012 09:37:39 -0500 Subject: [PATCH] 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 --- src/bin/lttng/lttng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; } } -- 2.34.1