Skip to content

Commit

Permalink
Fix OOB write for regs_write and replace hardcoded values.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 committed Feb 15, 2024
1 parent 9a6017b commit 44294a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions arch/M68K/M68KDisassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ typedef struct m68k_info {
unsigned int type;
unsigned int address_mask; /* Address mask to simulate address lines */
cs_m68k extension;
uint16_t regs_read[20]; // list of implicit registers read by this insn
uint16_t regs_read[MAX_IMPL_R_REGS]; // list of implicit registers read by this insn
uint8_t regs_read_count; // number of implicit registers read by this insn
uint16_t regs_write[20]; // list of implicit registers modified by this insn
uint16_t regs_write[MAX_IMPL_W_REGS]; // list of implicit registers modified by this insn
uint8_t regs_write_count; // number of implicit registers modified by this insn
uint8_t groups[8];
uint8_t groups[MAX_NUM_GROUPS];
uint8_t groups_count;
} m68k_info;

Expand Down
4 changes: 2 additions & 2 deletions arch/M68K/M68KInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ void M68K_printInst(MCInst* MI, SStream* O, void* PrinterInfo)

memcpy(&detail->m68k, ext, sizeof(cs_m68k));

memcpy(&detail->regs_read, &info->regs_read, regs_read_count * sizeof(uint16_t));
memcpy(&detail->regs_read, &info->regs_read, regs_read_count * sizeof(info->regs_read[0]));
detail->regs_read_count = regs_read_count;

memcpy(&detail->regs_write, &info->regs_write, regs_write_count * sizeof(uint16_t));
memcpy(&detail->regs_write, &info->regs_write, regs_write_count * sizeof(info->regs_write[0]));
detail->regs_write_count = regs_write_count;

memcpy(&detail->groups, &info->groups, groups_count);
Expand Down

0 comments on commit 44294a9

Please sign in to comment.