mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +00:00
sim65 path length safety for PVOpen
This commit is contained in:
parent
c097401f8b
commit
4d30333099
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user