1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-15 02:29:32 +00:00

sim65 path length safety for PVOpen

This commit is contained in:
bbbradsmith 2023-02-19 05:31:46 -05:00
parent c097401f8b
commit 4d30333099
2 changed files with 13 additions and 3 deletions

View File

@ -63,6 +63,7 @@
/* sim65 */
#include "6502.h"
#include "error.h"
#include "memory.h"
#include "paravirt.h"
@ -166,7 +167,7 @@ static void PVArgs (CPURegs* Regs)
static void PVOpen (CPURegs* Regs)
{
char Path[1024];
char Path[PVOPEN_PATH_SIZE];
int OFlag = O_INITIAL;
int OMode = 0;
unsigned RetVal, I = 0;
@ -183,9 +184,15 @@ static void PVOpen (CPURegs* Regs)
}
do {
Path[I] = MemReadByte (Name++);
if (!(Path[I] = MemReadByte ((Name + I) & 0xFFFF))) {
break;
}
++I;
if (I >= PVOPEN_PATH_SIZE) {
Error("PVOpen path too long at address $%04X",Name);
}
}
while (Path[I++]);
while (1);
Print (stderr, 2, "PVOpen (\"%s\", $%04X)\n", Path, Flags);

View File

@ -47,6 +47,9 @@
#define PARAVIRT_BASE 0xFFF4
/* Lowest address used by a paravirtualization hook */
#define PVOPEN_PATH_SIZE 1024
/* Maximum path size supported by PVOpen */
/*****************************************************************************/