mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-02 02:32:27 +00:00
Fix execution bug w/o binfmt_misc
The longjmp relocation in the master boot record coincidentally had a quote character in it, which caused the master boot record to be used when interpreter by the shell. The solution, is to move the grub stub below the long mode loader so the real mode loader relocation is near the master boot record. This change includes a regression test.
This commit is contained in:
parent
1a29424c52
commit
8f12cd980d
3 changed files with 61 additions and 46 deletions
|
@ -105,6 +105,20 @@ void RunApeTest(const char *path) {
|
|||
EXPECT_STREQN("MZqFpD", buf, 6);
|
||||
}
|
||||
|
||||
TEST(ape, noAccidentalQuotesInMasterBootRecord) {
|
||||
int i, quotes = 0;
|
||||
char buf[512] = {0};
|
||||
EXPECT_SYS(0, 3, open("bin/apetest.com", O_RDONLY));
|
||||
EXPECT_SYS(0, 512, read(3, buf, 512));
|
||||
EXPECT_SYS(0, 0, close(3));
|
||||
for (i = 0; i < 512; ++i) {
|
||||
if (buf[i] == '\'') {
|
||||
++quotes;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(1, quotes);
|
||||
}
|
||||
|
||||
TEST(apeNoModifySelf, runsWithoutModifyingSelf) {
|
||||
RunApeTest("bin/apetest.com");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue