AltairZ80: Fix potential buffer overrun compiler warnings

This commit is contained in:
Mark Pizzolato 2019-07-16 05:08:37 -07:00
parent d3228e85b0
commit 0b9cfa9b4d
3 changed files with 7 additions and 7 deletions

View file

@ -427,11 +427,11 @@ static int32 DAsm(char *S, const uint32 *val, const int32 useZ80Mnemonics, const
strncpy(R, T, T1 - T); strncpy(R, T, T1 - T);
R[T1 - T] = '\0'; R[T1 - T] = '\0';
printHex2(H, val[B++]); printHex2(H, val[B++]);
strcat(R, H); strlcat(R, H, sizeof (R));
strcat(R, T1 + 1); /* ok, since T1 is a short sub-string coming from one of the tables */ strlcat(R, T1 + 1, sizeof (R)); /* ok, since T1 is a short sub-string coming from one of the tables */
} }
else else
strcpy(R, T); /* ok, since T is a short string coming from one of the tables */ strlcpy(R, T, sizeof (R)); /* ok, since T is a short string coming from one of the tables */
if ( (P = strchr(R, '%')) ) { if ( (P = strchr(R, '%')) ) {
*P = C; *P = C;
if ( (P = strchr(P + 1, '%')) ) if ( (P = strchr(P + 1, '%')) )

View file

@ -54,7 +54,7 @@ extern int32 sio0d(const int32 port, const int32 io, const int32 data);
extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type, extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type,
int32 (*routine)(const int32, const int32, const int32), uint8 unmap); int32 (*routine)(const int32, const int32, const int32), uint8 unmap);
static char ansibuf[10]; static char ansibuf[32];
#define FW2_MAX_BOARDS 4 #define FW2_MAX_BOARDS 4
#define UNIT_V_FW2_VERBOSE (UNIT_V_UF + 1) /* verbose mode, i.e. show error messages */ #define UNIT_V_FW2_VERBOSE (UNIT_V_UF + 1) /* verbose mode, i.e. show error messages */

View file

@ -313,7 +313,7 @@ static char* make_signed_hex_str_32(uint val)
/* make string of immediate value */ /* make string of immediate value */
static char* get_imm_str_s(uint size) static char* get_imm_str_s(uint size)
{ {
static char str[15]; static char str[32];
if(size == 0) if(size == 0)
sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8())); sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8()));
else if(size == 1) else if(size == 1)
@ -325,7 +325,7 @@ static char* get_imm_str_s(uint size)
static char* get_imm_str_u(uint size) static char* get_imm_str_u(uint size)
{ {
static char str[15]; static char str[32];
if(size == 0) if(size == 0)
sprintf(str, "#$%x", read_imm_8() & 0xff); sprintf(str, "#$%x", read_imm_8() & 0xff);
else if(size == 1) else if(size == 1)
@ -3253,7 +3253,7 @@ unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_
char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type) char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
{ {
static char buff[100]; static char buff[200];
buff[0] = 0; buff[0] = 0;
m68k_disassemble(buff, pc, cpu_type); m68k_disassemble(buff, pc, cpu_type);
return buff; return buff;