|author||Justine Tunney <email@example.com>||2021-01-25 21:34:50 -0800|
|committer||Peter Stephenson <firstname.lastname@example.org>||2021-02-16 09:16:20 +0000|
Allow more scripts without #!
This change modifies the zsh binary safety check surrounding execve() so it can run shell scripts having concatenated binary content. We're using the same safety check as FreeBSD /bin/sh . POSIX was recently revised to require this behavior: "The input file may be of any type, but the initial portion of the file intended to be parsed according to the shell grammar (XREF to XSH 2.10.2 Shell Grammar Rules) shall consist of characters and shall not contain the NUL character. The shell shall not enforce any line length limits." "Earlier versions of this standard required that input files to the shell be text files except that line lengths were unlimited. However, that was overly restrictive in relation to the fact that shells can parse a script without a trailing newline, and in relation to a common practice of concatenating a shell script ending with an 'exit' or 'exec $command' with a binary data payload to form a single-file self-extracting archive."   One example use case of such scripts, is the Cosmopolitan C Library  which configuse the GNU Linker to output a polyglot shell+binary format that runs on Linux / Mac / Windows / FreeBSD / OpenBSD.  https://github.com/freebsd/freebsd-src/commit/9a1cd363318b7e9e70ef6af27d1675b371c16b1a  http://austingroupbugs.net/view.php?id=1250  http://austingroupbugs.net/view.php?id=1226#c4394  https://justine.lol/cosmopolitan/index.html
Diffstat (limited to 'Doc')
0 files changed, 0 insertions, 0 deletions