Fix asan crashes in the msp430 plugin
This commit is contained in:
parent
c9242c5a66
commit
7d61845ceb
4 changed files with 14 additions and 15 deletions
|
|
@ -14,7 +14,7 @@ static int msp430_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int le
|
|||
memset (&cmd, 0, sizeof (cmd));
|
||||
memset (op, 0, sizeof (RAnalOp));
|
||||
|
||||
ret = op->size = msp430_decode_command (buf, &cmd);
|
||||
ret = op->size = msp430_decode_command (buf, len, &cmd);
|
||||
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -445,16 +445,13 @@ static int decode_oneop_opcode(ut16 instr, ut16 op, struct msp430_cmd *cmd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int msp430_decode_command(const ut8 *in, struct msp430_cmd *cmd)
|
||||
{
|
||||
int msp430_decode_command(const ut8 *in, int len, struct msp430_cmd *cmd) {
|
||||
int ret = -1;
|
||||
ut16 instr;
|
||||
ut16 operand1, operand2;
|
||||
ut8 opcode;
|
||||
|
||||
instr = r_read_le16 (in);
|
||||
ut16 instr = r_read_le16 (in);
|
||||
|
||||
opcode = get_twoop_opcode(instr);
|
||||
ut8 opcode = get_twoop_opcode(instr);
|
||||
|
||||
switch (opcode) {
|
||||
case MSP430_MOV:
|
||||
|
|
@ -469,9 +466,11 @@ int msp430_decode_command(const ut8 *in, struct msp430_cmd *cmd)
|
|||
case MSP430_BIS:
|
||||
case MSP430_XOR:
|
||||
case MSP430_AND:
|
||||
cmd->type = MSP430_TWOOP;
|
||||
operand1 = r_read_at_le16 (in, 2);
|
||||
operand2 = r_read_at_le16 (in, 4);
|
||||
if (len >= 6) {
|
||||
cmd->type = MSP430_TWOOP;
|
||||
operand1 = r_read_at_le16 (in, 2);
|
||||
operand2 = r_read_at_le16 (in, 4);
|
||||
}
|
||||
ret = decode_twoop_opcode(instr, operand1, operand2, cmd);
|
||||
break;
|
||||
}
|
||||
|
|
@ -480,10 +479,11 @@ int msp430_decode_command(const ut8 *in, struct msp430_cmd *cmd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = decode_jmp(instr, cmd);
|
||||
ret = decode_jmp (instr, cmd);
|
||||
|
||||
if (ret > 0)
|
||||
if (ret > 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
operand1 = r_read_at_le16 (in, 2);
|
||||
ret = decode_oneop_opcode(instr, operand1, cmd);
|
||||
|
|
|
|||
|
|
@ -84,5 +84,5 @@ struct msp430_cmd {
|
|||
char operands[MSP430_INSTR_MAXLEN];
|
||||
};
|
||||
|
||||
int msp430_decode_command(const ut8 *instr, struct msp430_cmd *cmd);
|
||||
int msp430_decode_command(const ut8 *instr, int len, struct msp430_cmd *cmd);
|
||||
#endif /* MSP430_DISAS_H */
|
||||
|
|
|
|||
|
|
@ -8,10 +8,9 @@
|
|||
|
||||
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len)
|
||||
{
|
||||
int ret;
|
||||
struct msp430_cmd cmd;
|
||||
|
||||
ret = msp430_decode_command (buf, &cmd);
|
||||
int ret = msp430_decode_command (buf, len, &cmd);
|
||||
|
||||
if (ret > 0) {
|
||||
if (cmd.operands[0]) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue