mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
sim65 path length safety for PVOpen
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
|
|
||||||
/* sim65 */
|
/* sim65 */
|
||||||
#include "6502.h"
|
#include "6502.h"
|
||||||
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "paravirt.h"
|
#include "paravirt.h"
|
||||||
|
|
||||||
@@ -166,7 +167,7 @@ static void PVArgs (CPURegs* Regs)
|
|||||||
|
|
||||||
static void PVOpen (CPURegs* Regs)
|
static void PVOpen (CPURegs* Regs)
|
||||||
{
|
{
|
||||||
char Path[1024];
|
char Path[PVOPEN_PATH_SIZE];
|
||||||
int OFlag = O_INITIAL;
|
int OFlag = O_INITIAL;
|
||||||
int OMode = 0;
|
int OMode = 0;
|
||||||
unsigned RetVal, I = 0;
|
unsigned RetVal, I = 0;
|
||||||
@@ -183,9 +184,15 @@ static void PVOpen (CPURegs* Regs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
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);
|
Print (stderr, 2, "PVOpen (\"%s\", $%04X)\n", Path, Flags);
|
||||||
|
|
||||||
|
@@ -47,6 +47,9 @@
|
|||||||
#define PARAVIRT_BASE 0xFFF4
|
#define PARAVIRT_BASE 0xFFF4
|
||||||
/* Lowest address used by a paravirtualization hook */
|
/* Lowest address used by a paravirtualization hook */
|
||||||
|
|
||||||
|
#define PVOPEN_PATH_SIZE 1024
|
||||||
|
/* Maximum path size supported by PVOpen */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user