From 3c9ce852ec5f7c48ee60ba2c01ceae8aa31064d9 Mon Sep 17 00:00:00 2001 From: Etienne AUJAMES Date: Fri, 3 Jul 2020 10:17:29 +0200 Subject: [PATCH] LU-13746 utils: check argument logname presence in llog_print Correction of segfault in llog_print when no logname specified. example: lctl --device MGS llog_print Signed-off-by: Etienne AUJAMES Change-Id: I03a6c08dfc73ff8cb5861d162e21ce5aa581e197 Reviewed-on: https://review.whamcloud.com/39263 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu --- lustre/utils/obd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 1b033fd..d3762de 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -2983,7 +2983,7 @@ static int llog_parse_catalog_start_end(int *argc, char **argv[], if (*argc >= 1) { if (*catalog) { fprintf(stderr, - "%s: catalog is set, unknown argument '%s'\n", + "%s: logname is set, unknown argument '%s'\n", cmd, (*argv)[0]); return CMD_HELP; } @@ -2992,6 +2992,11 @@ static int llog_parse_catalog_start_end(int *argc, char **argv[], (*argv)++; } + if (*catalog == NULL) { + fprintf(stderr, "%s: no logname specified\n", cmd); + return CMD_HELP; + } + if (*argc >= 1) { if (*start != 1) { fprintf(stderr, -- 1.8.3.1