Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OOB read and wries #2273

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void map_add_implicit_read(MCInst *MI, uint32_t Reg)
return;

uint16_t *regs_read = MI->flat_insn->detail->regs_read;
for (int i = 0; i < MAX_IMPL_W_REGS; ++i) {
for (int i = 0; i < MAX_IMPL_R_REGS; ++i) {
if (i == MI->flat_insn->detail->regs_read_count) {
regs_read[i] = Reg;
MI->flat_insn->detail->regs_read_count++;
Expand Down
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
Loading