[llvm] c299f35 - [SystemZ] Fix disassembler crashes
Ulrich Weigand via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 20 01:22:00 PDT 2020
Author: Ulrich Weigand
Date: 2020-10-20T10:21:42+02:00
New Revision: c299f3555d77aef598506b254dcf728928e616de
URL: https://github.com/llvm/llvm-project/commit/c299f3555d77aef598506b254dcf728928e616de
DIFF: https://github.com/llvm/llvm-project/commit/c299f3555d77aef598506b254dcf728928e616de.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
index e42aa14fe589..e81db1030c01 100644
--- a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
+++ b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp
@@ -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;
More information about the llvm-commits
mailing list