summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Huth <huth@tuxfamily.org>2023-11-11 15:03:27 (GMT)
committerThomas Huth <huth@tuxfamily.org>2023-11-11 15:03:27 (GMT)
commit8a0c86bc250bb305c8c9cacc766b06ae52a03457 (patch)
treebf4783b148acb2e44cbc96f18b07ad6088554ac0
parent0828e2819c788e314cdeb0ff9b99d7928789f774 (diff)
downloadhatari-8a0c86bc250bb3.zip
hatari-8a0c86bc250bb3.tar.gz
Ignore symbol table length if it contains a value that is too big
Original TOS does the same, and there are some programs in the wild that apparently abuse the symbol table size field for other purposes, so we should ignore it in Hatari, too, to be able to load those baddies.
-rw-r--r--src/gemdos.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/gemdos.c b/src/gemdos.c
index 780d7e2..49c04e5 100644
--- a/src/gemdos.c
+++ b/src/gemdos.c
@@ -4342,13 +4342,24 @@ int GemDOS_LoadAndReloc(const char *psPrgName, uint32_t baseaddr, bool bFullBpSe
return 0;
}
- nRelTabIdx = 0x1c + nTextLen + nDataLen + nSymLen;
+ nRelTabIdx = 0x1c + nTextLen + nDataLen;
if (nRelTabIdx > nFileSize - 3)
{
free(prg);
Log_Printf(LOG_ERROR, "Can not parse relocation table of '%s'.\n", psPrgName);
return GEMDOS_EPLFMT;
}
+ if (nRelTabIdx + nSymLen <= nFileSize - 3)
+ {
+ nRelTabIdx += nSymLen;
+ }
+ else
+ {
+ /* Original TOS ignores the error if the symbol table length
+ * is too, big, so just log a warning here instead of failing */
+ Log_Printf(LOG_WARN, "Symbol table length of '%s' is too big!\n", psPrgName);
+ }
+
nRelOff = (prg[nRelTabIdx] << 24) | (prg[nRelTabIdx + 1] << 16)
| (prg[nRelTabIdx + 2] << 8) | prg[nRelTabIdx + 3];