1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 07:29:33 +00:00

Merge pull request #1993 from bbbradsmith/sim65_pvopen_safety

sim65 path length safety for PVOpen
This commit is contained in:
Bob Andrews 2023-02-19 16:27:46 +01:00 committed by GitHub
commit 0ff18510c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 */
/*****************************************************************************/