[wasm] readSection: Avoid reading past eof (fixes oss-fuzz #3219)
authorVedant Kumar <vsk@apple.com>
Mon, 23 Oct 2017 18:04:34 +0000 (18:04 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 23 Oct 2017 18:04:34 +0000 (18:04 +0000)
commit35b50a83aba3a5eedd3395341b5be76600a6841c
treef70f4bba61b5f853cf7edcf6653510af4d8505b7
parent1108d072f47b74ff671df61b434a18da02f4dd3e
[wasm] readSection: Avoid reading past eof (fixes oss-fuzz #3219)

A wasm file crafted with a bogus section size can trigger an ASan issue
in the DWARFObjInMemory constructor. Nip the problem in the bud when we
read the wasm section.

Found by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3219

Differential Revision: https://reviews.llvm.org/D38777

llvm-svn: 316357
llvm/lib/Object/WasmObjectFile.cpp
llvm/test/tools/llvm-objdump/Inputs/corrupt-section.wasm [new file with mode: 0644]
llvm/test/tools/llvm-objdump/wasm-corrupt-section.test [new file with mode: 0644]