From 042487c2b460c759f5066cd9792d2f385a146f94 Mon Sep 17 00:00:00 2001 From: agnostic-apollo Date: Sat, 11 Jun 2022 13:52:10 +0500 Subject: [PATCH] Changed: Ensure `AppShell` executable is not `null` before trying to execute it --- .../termux/shared/shell/command/runner/app/AppShell.java | 7 +++++++ termux-shared/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+) diff --git a/termux-shared/src/main/java/com/termux/shared/shell/command/runner/app/AppShell.java b/termux-shared/src/main/java/com/termux/shared/shell/command/runner/app/AppShell.java index 8eb3b899..ad082392 100644 --- a/termux-shared/src/main/java/com/termux/shared/shell/command/runner/app/AppShell.java +++ b/termux-shared/src/main/java/com/termux/shared/shell/command/runner/app/AppShell.java @@ -69,6 +69,13 @@ public final class AppShell { final AppShellClient appShellClient, @NonNull final ShellEnvironmentClient shellEnvironmentClient, final boolean isSynchronous) { + if (executionCommand.executable == null || executionCommand.executable.isEmpty()) { + executionCommand.setStateFailed(Errno.ERRNO_FAILED.getCode(), + currentPackageContext.getString(R.string.error_executable_unset, executionCommand.getCommandIdAndLabelLogString())); + AppShell.processAppShellResult(null, executionCommand); + return null; + } + if (executionCommand.workingDirectory == null || executionCommand.workingDirectory.isEmpty()) executionCommand.workingDirectory = shellEnvironmentClient.getDefaultWorkingDirectoryPath(); if (executionCommand.workingDirectory.isEmpty()) diff --git a/termux-shared/src/main/res/values/strings.xml b/termux-shared/src/main/res/values/strings.xml index a0111fc3..c9f1622b 100644 --- a/termux-shared/src/main/res/values/strings.xml +++ b/termux-shared/src/main/res/values/strings.xml @@ -62,6 +62,7 @@ Sending SIGKILL to process on user request or because android is killing the execution service + Executable not set \"%1$s\" for shell command Execution has been cancelled since execution service is being killed Failed to execute \"%1$s\" termux session command Failed to execute \"%1$s\" app shell command