diff options
-rw-r--r-- | src/binary-reader-objdump.cc | 6 | ||||
-rw-r--r-- | test/binary/bad-relocs.txt | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index cc874a26..66c858ed 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -175,6 +175,12 @@ void BinaryReaderObjdumpBase::PrintRelocation(const Reloc& reloc, } Result BinaryReaderObjdumpBase::OnRelocCount(Index count, Index section_index) { + if (section_index >= section_types_.size()) { + fprintf(stderr, "invalid relocation section index: %" PRIindex "\n", + section_index); + reloc_section_ = BinarySection::Invalid; + return Result::Error; + } reloc_section_ = section_types_[section_index]; return Result::Ok; } diff --git a/test/binary/bad-relocs.txt b/test/binary/bad-relocs.txt new file mode 100644 index 00000000..6240ced0 --- /dev/null +++ b/test/binary/bad-relocs.txt @@ -0,0 +1,27 @@ +;;; TOOL: run-objdump-gen-wasm +;;; ARGS: -x +magic +version +section("reloc.BAD") { + reloc_section[99] + reloc_count[0] +} +(;; STDERR ;;; +invalid relocation section index: 99 +0000016: warning: OnRelocCount callback failed +invalid relocation section index: 99 +invalid relocation section index: 99 +;;; STDERR ;;) +(;; STDOUT ;;; + +bad-relocs.wasm: file format wasm 0x1 + +Section Details: + +Custom: + - name: "reloc.BAD" + - relocations for section: 99 () [0] + +Code Disassembly: + +;;; STDOUT ;;) |