4 ms·
Look for “POSIX” on https://justine.lol/cosmo3/ https://justine.lol/cosmo3/
by xiaq 2y ago
Look for “POSIX” on https://justine.lol/cosmo3/ https://justine.lol/cosmo3/
- oguz-ismail 2y agoPOSIX now says: >The input file can be of any type, but the initial portion of the file intended to be parsed according to the shell grammar [...] shall not contain the NUL character. But the initial portion of, https://cosmo.zip/pub/cosmos/bin/cat https://cosmo.zip/pub/cosmos/bin/cat for example, does contain the NUL character.
- jart 2y agoCosmo author here. I'm familiar with the new rules. They were first implemented in https://github.com/freebsd/freebsd-src/commit/e0f5c1387df23c8c4811f5b24a7ef6ecac51a71a https://github.com/freebsd/freebsd-src/commit/e0f5c1387df23c... which makes a clear intentional allowance for what APE is doing. If you look at the hex dump: main jart@luna:~/llamafile$ hexdump -C cat | head 00000000 4d 5a 71 46 70 44 3d 27 0a 0a 00 10 00 f8 00 00 |MZqFpD='........| 00000010 00 00 00 00 00 01 00 08 40 00 00 00 00 00 00 00 |........@.......| You'll notice there's no NUL characters on the first line, and that the subsequent NULs are escaped by a single-quoted string, which is legal. The rules used to be more restrictive but they relaxed the requirements specifically so I could work on APE. Jilles Tjoelker is one of the heroes who made that possible.
- oguz-ismail 2y ago[T]he initial portion doesn't mean the first line, it means the script part of a file consisting of a shell script and a binary payload, separated by `exit', `exec whatever', etc. A good example is the Oracle Developer Studio installation script. You can write to Austin Group mailing list and ask for clarification if you want.