[git commit] ash: reject unknown long options

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 27 19:29:05 UTC 2024


commit: https://git.busybox.net/busybox/commit/?id=24aa93d5382f2365c35d6e804b748e0a1febf2f6
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Commit 64f70cc755 (Add --login support) added code in options()
to handle the bash-compatible '--login' option.  In doing so it
committed BusyBox ash to silently accepting all other long
options.

Restore compatibility with other ash variants by rejecting unknown
long options.

function                                             old     new   delta
options                                              589     624     +35

Signed-off-by: Ron Yorston <rmy at pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index bbd730770..8e029765d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -11502,11 +11502,12 @@ options(int *login_sh)
 				if (val && (c == '-')) { /* long options */
 					if (strcmp(p, "login") == 0) {
 						*login_sh = 1;
+						break;
 					}
 /* TODO: --noprofile: e.g. if I want to run emergency shell from sulogin,
  * I want minimal/no shell init scripts - but it insists on running it as "-ash"...
  */
-					break;
+					ash_msg_and_raise_error("bad option '%s'", p - 2);
 				}
 			}
 			if (c == 'o') {


More information about the busybox-cvs mailing list