Skip to content

Commit

Permalink
All: Declare sim_stop_messages as an array SCPE_BASE long
Browse files Browse the repository at this point in the history
This avoids a potential invalid pointer dereference when formatting
the return value from sim_instr() if it is < SCPE_BASE but greater
than the previously defined static array size.sizeof

Update simh.doc to reflect this generic change.
  • Loading branch information
markpizz committed Sep 2, 2020
1 parent 782fe16 commit ae825c9
Show file tree
Hide file tree
Showing 46 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion 3B2/3b2_400_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Reserved Instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion ALTAIR/altair_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O Instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion AltairZ80/altairz80_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ DEVICE *sim_devices[] = {

static char memoryAccessMessage[256];
static char instructionMessage[256];
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"HALT instruction",
"Breakpoint",
memoryAccessMessage,
Expand Down
2 changes: 1 addition & 1 deletion B5500/b5500_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DEVICE *sim_devices[] = {
};

/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
0,
};

Expand Down
2 changes: 1 addition & 1 deletion BESM6/besm6_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ DEVICE *sim_devices[] = {
0
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Неизвестная ошибка", /* Unknown error */
"Останов", /* STOP */
"Точка останова", /* Emulator breakpoint */
Expand Down
2 changes: 1 addition & 1 deletion CDC1700/cdc1700_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"OK",
"Indirect addressing loop count exceeded",
"Selective Stop",
Expand Down
2 changes: 1 addition & 1 deletion GRI/gri_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unimplemented unit",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion H316/h316_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unimplemented instruction",
"Unimplemented I/O device",
Expand Down
2 changes: 1 addition & 1 deletion HP2100/hp2100_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ DEVICE *sim_devices [] = { /* an array of pointers to the s
#define DEVICE_COUNT (sizeof sim_devices / sizeof sim_devices [0] - 1) /* the count excludes the NULL pointer */


const char *sim_stop_messages [] = { /* an array of pointers to the stop messages in STOP_nnn order */
const char *sim_stop_messages [SCPE_BASE] = { /* an array of pointers to the stop messages in STOP_nnn order */
"Impossible error", /* 0 (never returned) */
"Unimplemented instruction", /* STOP_UNIMPL */
"Unassigned select code", /* STOP_UNSC */
Expand Down
2 changes: 1 addition & 1 deletion HP3000/hp3000_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ DEVICE *sim_devices [] = { /* an array of pointers to the s
#define DEVICE_COUNT (sizeof sim_devices / sizeof sim_devices [0] - 1)


const char *sim_stop_messages [] = { /* an array of pointers to the stop messages in STOP_nnn order */
const char *sim_stop_messages [SCPE_BASE] = { /* an array of pointers to the stop messages in STOP_nnn order */
"Impossible error", /* 0 (never returned) */
"System halt", /* STOP_SYSHALT */
"Unimplemented instruction", /* STOP_UNIMPL */
Expand Down
2 changes: 1 addition & 1 deletion I1401/i1401_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unimplemented instruction",
"Non-existent memory",
Expand Down
2 changes: 1 addition & 1 deletion I1620/i1620_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion I650/i650_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ DIB mt_dib = { 5, &mt_cmd, &mt_ini };
DIB dsk_dib = { 4, &mt_cmd, &dsk_ini };

/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion I7000/i7010_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DIB com_dib = { CH_TYP_79XX|CH_TYP_UREC, 0, 04200, 07700, &com_cmd, NULL };


/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion I7000/i701_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ DIB mt_dib = { CH_TYP_PIO, NUM_UNITS_MT, 0400, 07770, &mt_cmd, &mt_ini };


/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion I7000/i7070_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ DIB com_dib = { CH_TYP_79XX, 0, 0, 0, &com_cmd, NULL };
#endif

/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion I7000/i7080_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ DIB com_dib = { CH_TYP_79XX, 0, 0, 0, &com_cmd, NULL };
#endif

/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion I7000/i7090_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ DIB hsdrm_dib = { CH_TYP_SPEC, 1, 0330, 0777, &hsdrm_cmd, &hsdrm_ini };


/* Simulator stop codes */
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion I7094/i7094_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ DEVICE *sim_devices[] = {

char ch_bkpt_msg[] = "Channel A breakpoint, CLC: xxxxxx";

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion Ibm1130/ibm1130_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Wait",
"Invalid command",
Expand Down
2 changes: 1 addition & 1 deletion Intel-Systems/ibmpc/ibmpc_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O Instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion Intel-Systems/ibmpcxt/ibmpcxt_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O Instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion Interdata/id16_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Reserved instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion Interdata/id32_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Reserved instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion LGP/lgp_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"STOP",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion NOVA/nova_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion PDP1/pdp1_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Undefined instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion PDP10/kx10_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion PDP10/pdp10_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion PDP11/pdp11_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Red stack trap",
"Odd address trap",
Expand Down
2 changes: 1 addition & 1 deletion PDP18B/pdp18b_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Undefined instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion PDP8/pdp8_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unimplemented instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion PDQ-3/pdq3_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DEVICE *sim_devices[] = {
&tim_dev,
NULL
};
const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"---",
"PC Breakpoint",
"MEM Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion S3/s3_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O Instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion SAGE/m68k_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ t_stat sim_load(FILE* fptr, CONST char* cptr, CONST char* fnam, t_bool flag)
return SCPE_OK;
}

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"---",
"PC Breakpoint",
"MEM Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion SDS/sds_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"IO device not ready",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion SSEM/ssem_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Stop",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion TX-0/tx0_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Undefined instruction",
"HALT instruction",
Expand Down
2 changes: 1 addition & 1 deletion VAX/vax_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ REG *sim_PC = &cpu_reg[0];

int32 sim_emax = 60;

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion alpha/alpha_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ REG *sim_PC = &cpu_reg[0];

int32 sim_emax = 1;

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
Binary file modified doc/simh.doc
Binary file not shown.
2 changes: 1 addition & 1 deletion imlac/imlac_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"HALT instruction",
"Breakpoint",
Expand Down
2 changes: 1 addition & 1 deletion sigma/sigma_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Invalid I/O configuration",
"Breakpoint",
Expand Down
3 changes: 2 additions & 1 deletion sim_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
sim_devices[] array of pointers to simulated devices
sim_PC pointer to saved PC register descriptor
sim_interval simulator interval to next event
sim_stop_messages[] array of pointers to stop messages
sim_stop_messages[SCPE_BASE]
array of pointers to stop messages
sim_instr() instruction execution routine
sim_load() binary loader routine
sim_emax maximum number of words in an instruction
Expand Down
2 changes: 1 addition & 1 deletion swtp6800/swtp6800/mp-a2_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ DEVICE *sim_devices[] = {
NULL
};

const char *sim_stop_messages[] = {
const char *sim_stop_messages[SCPE_BASE] = {
"Unknown error",
"Unknown I/O Instruction",
"HALT instruction",
Expand Down
Loading

0 comments on commit ae825c9

Please sign in to comment.