[PATCH] D39206: [libunwind] Add missing checks for register number
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 00:17:10 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316415: Add missing checks for register number (authored by mstorsjo).
Changed prior to commit:
https://reviews.llvm.org/D39206?vs=119940&id=120001#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39206
Files:
libunwind/trunk/src/DwarfParser.hpp
Index: libunwind/trunk/src/DwarfParser.hpp
===================================================================
--- libunwind/trunk/src/DwarfParser.hpp
+++ libunwind/trunk/src/DwarfParser.hpp
@@ -605,6 +605,13 @@
break;
case DW_CFA_val_offset:
reg = addressSpace.getULEB128(p, instructionsEnd);
+ if (reg > kMaxRegisterNumber) {
+ fprintf(stderr,
+ "malformed DW_CFA_val_offset DWARF unwind, reg (%" PRIu64
+ ") out of range\n",
+ reg);
+ return false;
+ }
offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
* cieInfo.dataAlignFactor;
results->savedRegisters[reg].location = kRegisterOffsetFromCFA;
@@ -668,6 +675,12 @@
switch (opcode & 0xC0) {
case DW_CFA_offset:
reg = operand;
+ if (reg > kMaxRegisterNumber) {
+ fprintf(stderr, "malformed DW_CFA_offset DWARF unwind, reg (%" PRIu64
+ ") out of range\n",
+ reg);
+ return false;
+ }
offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd)
* cieInfo.dataAlignFactor;
results->savedRegisters[reg].location = kRegisterInCFA;
@@ -682,6 +695,12 @@
break;
case DW_CFA_restore:
reg = operand;
+ if (reg > kMaxRegisterNumber) {
+ fprintf(stderr, "malformed DW_CFA_restore DWARF unwind, reg (%" PRIu64
+ ") out of range\n",
+ reg);
+ return false;
+ }
results->savedRegisters[reg] = initialState.savedRegisters[reg];
_LIBUNWIND_TRACE_DWARF("DW_CFA_restore(reg=%" PRIu64 ")\n",
static_cast<uint64_t>(operand));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39206.120001.patch
Type: text/x-patch
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171024/fd0821ad/attachment.bin>
More information about the cfe-commits
mailing list