"realpath" loadable (in the examples/loadables dir) infinite loops

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"realpath" loadable (in the examples/loadables dir) infinite loops

gazelle
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux shell 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
        Command "realpath --help" causes infinite loop.

Repeat-By:
        enable -f /usr/local/lib/bash/realpath realpath
        realpath --help

        causes infinite loop of:

realpath: usage: realpath [-csv] pathname [pathname...]
realpath: usage: realpath [-csv] pathname [pathname...]
realpath: usage: realpath [-csv] pathname [pathname...]
realpath: usage: realpath [-csv] pathname [pathname...]
realpath: usage: realpath [-csv] pathname [pathname...]
realpath: usage: realpath [-csv] pathname [pathname...]

        until the shell is killed by signal 9 from another terminal.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "realpath" loadable (in the examples/loadables dir) infinite loops

Eduardo A. Bustamante López
On Mon, Jun 19, 2017 at 07:18:11PM -0600, [hidden email] wrote:
[...]
> Description:
> Command "realpath --help" causes infinite loop.

I can reproduce this in the `devel' branch.

The getopts loop is missing a `return' to break out of it. This should
fix it:

diff --git a/examples/loadables/realpath.c b/examples/loadables/realpath.c
index b19b87fb..7ea9a995 100644
--- a/examples/loadables/realpath.c
+++ b/examples/loadables/realpath.c
@@ -88,6 +88,7 @@ WORD_LIST *list;
  break;
  default:
  builtin_usage();
+ return (EX_USAGE);
  }
  }

--
Eduardo Bustamante
https://dualbus.me/

Loading...