cmd: version command should not call before or after procs 45/14645/3
authorMark Vitale <mvitale@sinenomine.net>
Tue, 22 Jun 2021 03:29:09 +0000 (23:29 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Sat, 26 Jun 2021 04:15:22 +0000 (00:15 -0400)
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 <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 <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/cmd/cmd.c

index 4aa9242..f09063f 100644 (file)
@@ -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;
     }