mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 03:10:27 +00:00
Make ape.S shell script magic less prone to accidental breakage
The metal boot sector code was wrapped in a single-quoted string, like so: MZqFpD=' ...MZ HEADER... ...E_LFANEW... ...BIOS BOOT SECTOR...' This might break the shell code loader if the boot sector code contains a 0x27 (single quote) byte. This patch wraps the boot sector code in a here-document instead: MZqFpD=' ...MZ HEADER...' <<'@' ...E_LFANEW... ...BIOS BOOT SECTOR... @ This is harder to break — when interpreted as a shell script, the code can only accidentally terminate the here-document if there is a "\n@\n" sequence inside the BIOS boot portion.
This commit is contained in:
parent
09811e739f
commit
0bf8e580c9
1 changed files with 2 additions and 1 deletions
|
@ -125,6 +125,7 @@ ape_mz: .asciz "MZqFpD='\n" # Mark 'Zibo' Joseph Zbikowski
|
||||||
.org 0x24 # MZ: bytes reserved for you
|
.org 0x24 # MZ: bytes reserved for you
|
||||||
.ascii "JT" # MZ: OEM identifier
|
.ascii "JT" # MZ: OEM identifier
|
||||||
.short 0 # MZ: OEM information
|
.short 0 # MZ: OEM information
|
||||||
|
.ascii "' <<'@'\n"
|
||||||
.org 0x40-4 # MZ: bytes reserved for you
|
.org 0x40-4 # MZ: bytes reserved for you
|
||||||
#if SupportsWindows() || SupportsMetal()
|
#if SupportsWindows() || SupportsMetal()
|
||||||
.long RVA(ape_pe) # PE: the new technology
|
.long RVA(ape_pe) # PE: the new technology
|
||||||
|
@ -549,7 +550,7 @@ ape_disk:
|
||||||
the bourne executable & linkable format */
|
the bourne executable & linkable format */
|
||||||
|
|
||||||
#if SupportsWindows() || SupportsMetal() || SupportsXnu()
|
#if SupportsWindows() || SupportsMetal() || SupportsXnu()
|
||||||
apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
apesh: .ascii "\n@\n#'\"\n" # sixth edition shebang
|
||||||
// Until all operating systems can be updated to support APE,
|
// Until all operating systems can be updated to support APE,
|
||||||
// we have a beautiful, yet imperfect workaround, which is to
|
// we have a beautiful, yet imperfect workaround, which is to
|
||||||
// modify the binary to follow the local system's convention.
|
// modify the binary to follow the local system's convention.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue