forked from OSchip/llvm-project
[WebAssembly] Fix overflow for input with missing version
Differential revision: https://reviews.llvm.org/D37070 llvm-svn: 311605
This commit is contained in:
parent
15848e5977
commit
a845167dca
|
@ -203,7 +203,16 @@ WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
|
|||
object_error::parse_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t *Eof = getPtr(getData().size());
|
||||
const uint8_t *Ptr = getPtr(4);
|
||||
|
||||
if (Ptr + 4 > Eof) {
|
||||
Err = make_error<StringError>("Missing version number",
|
||||
object_error::parse_failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Header.Version = readUint32(Ptr);
|
||||
if (Header.Version != wasm::WasmVersion) {
|
||||
Err = make_error<StringError>("Bad version number",
|
||||
|
@ -211,7 +220,6 @@ WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
|
|||
return;
|
||||
}
|
||||
|
||||
const uint8_t *Eof = getPtr(getData().size());
|
||||
WasmSection Sec;
|
||||
while (Ptr < Eof) {
|
||||
if ((Err = readSection(Sec, Ptr, getPtr(0))))
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,2 @@
|
|||
# RUN: not llvm-objdump -h %p/Inputs/WASM/missing-version.wasm 2>&1 | FileCheck %s
|
||||
# CHECK: {{.*}}: Missing version number
|
Loading…
Reference in New Issue