Whamcloud - gitweb
LU-18836 utils: lctl SIGSEGV in parser.c 68/58468/2
authorFrank Sehr <fsehr@whamcloud.com>
Wed, 19 Mar 2025 19:50:34 +0000 (12:50 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 31 Mar 2025 05:57:32 +0000 (05:57 +0000)
Added additional checks for NULL pointers in execute_line().

Test-Parameters: trivial
Signed-off-by: Frank Sehr <fsehr@whamcloud.com>
Change-Id: I0e470edadd3b4db4c47f0f42f52d34d541290224
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58468
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage@whamcloud.com>
Reviewed-by: Manish Regmi <mregmi@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/util/parser.c

index 1d3c205..4bdce22 100644 (file)
@@ -359,12 +359,18 @@ static int execute_line(char *line)
                fprintf(stderr, "No such command. Try --list-commands to see available commands.\n");
                break;
        case CMD_INCOMPLETE:
+               if (cmd == NULL || cmd->pc_sub_cmd == NULL) {
+                       fprintf(stderr, "'%s' incomplete command.\n", line);
+                       return rc;
+               }
+
                fprintf(stderr,
-                       "'%s' incomplete command.  Use '%s x' where x is one of:\n",
+                       "'%s' incomplete command.  Use '%s x' where x is one of:\n\t",
                        line, line);
-               fprintf(stderr, "\t");
+
                for (i = 0; cmd->pc_sub_cmd[i].pc_name; i++)
                        fprintf(stderr, "%s ", cmd->pc_sub_cmd[i].pc_name);
+
                fprintf(stderr, "\n");
                break;
        case CMD_COMPLETE: