diff --git a/run-tests.sh b/run-tests.sh index 6720343..0c831d7 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -9,7 +9,7 @@ for f in tests/*.sh; do ACTUAL_FILE=$f-actual rm -f $ACTUAL_FILE - $f myarg1 myarg2 > $ACTUAL_FILE + $f myarg1 myarg2 &> $ACTUAL_FILE if cmp --silent $ACTUAL_FILE $EXPECTED_FILE; then printf " OK\n" diff --git a/termux-exec.c b/termux-exec.c index 66e9622..51fcb22 100644 --- a/termux-exec.c +++ b/termux-exec.c @@ -26,6 +26,9 @@ int execve(const char* filename, char* const* argv, char *const envp[]) char filename_buffer[512]; filename = termux_rewrite_executable(filename, filename_buffer, sizeof(filename_buffer)); + // Error out if the file is not executable: + if (access(filename, X_OK) != 0) goto final; + fd = open(filename, O_RDONLY); if (fd == -1) goto final; diff --git a/tests/not-executable.sh b/tests/not-executable.sh new file mode 100644 index 0000000..2a22daa --- /dev/null +++ b/tests/not-executable.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo hello diff --git a/tests/not-executable.sh-expected b/tests/not-executable.sh-expected new file mode 100644 index 0000000..5e7557b --- /dev/null +++ b/tests/not-executable.sh-expected @@ -0,0 +1 @@ +./run-tests.sh: line 12: tests/not-executable.sh: Permission denied