]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sh: Allow more scripts without #!
authorjilles <jilles@FreeBSD.org>
Sat, 30 May 2020 16:00:49 +0000 (16:00 +0000)
committerjilles <jilles@FreeBSD.org>
Sat, 30 May 2020 16:00:49 +0000 (16:00 +0000)
commit9a1cd363318b7e9e70ef6af27d1675b371c16b1a
tree720522fec5317bf9886be3cf971e5164c6facc5b
parent82b2ae11e9d4ff281aaa679d6884ea087d829932
sh: Allow more scripts without #!

Austin Group bugs #1226 and #1250 changed the requirements for shell scripts
without #! (POSIX does not specify #!; this is about the shell execution
when execve(2) returns an [ENOEXEC] error).

POSIX says we shall allow execution if the initial part intended to be
parsed by the shell consists of characters and does not contain the NUL
character.  This allows concatenating a shell script (ending with exec or
exit) and a binary payload.

In order to reject common binary files such as PNG images, check that there
is a lowercase letter or expansion before the last newline before the NUL
character, in addition to the check for the newline character suggested by
POSIX.
bin/sh/exec.c
bin/sh/tests/execution/Makefile
bin/sh/tests/execution/shellproc6.0 [new file with mode: 0644]