[SystemZ] Fix disassembler crashes

The "Size" value returned by SystemZDisassembler::getInstruction is
used by common code even in the case where the routine returns
failure.  If that Size value exceeds the number of bytes remaining
in the section, that could cause disassembler crashes.

Fixed by never returning more than the number of bytes remaining.
This commit is contained in:
Ulrich Weigand 2020-10-20 10:19:15 +02:00
parent 991e86156c
commit c299f3555d
1 changed files with 3 additions and 1 deletions

View File

@ -468,8 +468,10 @@ DecodeStatus SystemZDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
}
// Read any remaining bytes.
if (Bytes.size() < Size)
if (Bytes.size() < Size) {
Size = Bytes.size();
return MCDisassembler::Fail;
}
// Construct the instruction.
uint64_t Inst = 0;