From 6240ae64e694cd74ca9ebcb1da96b103936b83c3 Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Mon, 21 Jun 2021 23:29:09 -0400 Subject: [PATCH] cmd: version command should not call before or after procs Since the original IBM code import, the cmd_Dispatch processor has avoided calling beforeProc and afterProc for the built-in 'help' and 'apropos' commands. This is important, because these procs may rely on application-defined common arguments (e.g., -cell or -noauth) for proper operation. However, application common arguments are not defined for built-in commands 'help' and 'apropos'. Unfortunately, when a new built-in 'version' command was added (350c140d89198cb7 libcmd-support-version-switch-20060630), it was not exempted from the before and after procs. In order to avoid a segmentation fault in 'libadmin/test/afscp version', modify cmd to also avoid calling beforeProc and afterProc for the 'version' command. Change-Id: Ic899397de808fd6c4a5f66a0f5add102340064e6 Reviewed-on: https://gerrit.openafs.org/14645 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/cmd/cmd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/cmd.c b/src/cmd/cmd.c index 4aa9242..f09063f 100644 --- a/src/cmd/cmd.c +++ b/src/cmd/cmd.c @@ -1107,10 +1107,9 @@ cmd_Dispatch(int argc, char **argv) /* * Before calling the beforeProc and afterProc and all the implications - * from those calls, check if the help procedure was called and call it - * now. + * from those calls, handle any built-in commands. */ - if ((ts->proc == HelpProc) || (ts->proc == AproposProc)) { + if ((ts->proc == HelpProc) || (ts->proc == AproposProc) || (ts->proc == VersionProc)) { code = (*ts->proc) (ts, ts->rock); goto out; } -- 1.9.4