ash: do not use "safe applets" in non-standalone shell
diff --git a/shell/ash.c b/shell/ash.c
index 371b5d9..335dcba 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6455,7 +6455,9 @@
 
 /* ============ find_command */
 
-static int is_safe_applet(char *name)
+#if ENABLE_FEATURE_SH_STANDALONE_SHELL
+static int
+is_safe_applet(char *name)
 {
 	/* It isn't a bug to have non-existent applet here... */
 	/* ...just a waste of space... */
@@ -6488,6 +6490,7 @@
 
 	return 0;
 }
+#endif
 
 struct builtincmd {
 	const char *name;
@@ -6551,27 +6554,26 @@
 tryexec(char *cmd, char **argv, char **envp)
 {
 	int repeated = 0;
-	struct BB_applet *a;
-	int argc = 0;
-	char **c;
 
-	if (strchr(cmd, '/') == NULL
-	 && (a = find_applet_by_name(cmd)) != NULL
-	 && is_safe_applet(cmd)
-	) {
-		c = argv;
-		while (*c != NULL) {
-			c++; argc++;
-		}
-		applet_name = cmd;
-		exit(a->main(argc, argv));
-	}
 #if ENABLE_FEATURE_SH_STANDALONE_SHELL
-	if (find_applet_by_name(cmd) != NULL) {
-		/* re-exec ourselves with the new arguments */
-		execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp);
-		/* If they called chroot or otherwise made the binary no longer
-		 * executable, fall through */
+	if (strchr(cmd, '/') == NULL) {
+		struct BB_applet *a;
+		char **c;
+
+		a = find_applet_by_name(cmd);
+		if (a) {
+			if (is_safe_applet(cmd)) {
+				c = argv;
+				while (*c)
+					c++;
+				applet_name = cmd;
+				exit(a->main(c - argv, argv));
+			}
+			/* re-exec ourselves with the new arguments */
+			execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp);
+			/* If they called chroot or otherwise made the binary no longer
+			 * executable, fall through */
+		}
 	}
 #endif
 
@@ -6619,7 +6621,7 @@
 
 	clearredir(1);
 	envp = environment();
-	if (strchr(argv[0], '/') || is_safe_applet(argv[0])
+	if (strchr(argv[0], '/')
 #if ENABLE_FEATURE_SH_STANDALONE_SHELL
 	 || find_applet_by_name(argv[0])
 #endif
@@ -11141,13 +11143,13 @@
 		entry->u.index = -1;
 		return;
 	}
-#endif
-
+	/* Already caught above
 	if (is_safe_applet(name)) {
 		entry->cmdtype = CMDNORMAL;
 		entry->u.index = -1;
 		return;
-	}
+	}*/
+#endif
 
 	updatetbl = (path == pathval());
 	if (!updatetbl) {