[Wasm] Add missing EOF checks for floats

Adds the same checks we already do for ints to floats.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8698
llvm-svn: 341216
This commit is contained in:
Jonas Devlieghere 2018-08-31 14:54:01 +00:00
parent c807ce0ee4
commit e3d6b9786e
1 changed files with 4 additions and 0 deletions

View File

@ -82,6 +82,8 @@ static uint32_t readUint32(WasmObjectFile::ReadContext &Ctx) {
}
static int32_t readFloat32(WasmObjectFile::ReadContext &Ctx) {
if (Ctx.Ptr + 4 > Ctx.End)
report_fatal_error("EOF while reading float64");
int32_t Result = 0;
memcpy(&Result, Ctx.Ptr, sizeof(Result));
Ctx.Ptr += sizeof(Result);
@ -89,6 +91,8 @@ static int32_t readFloat32(WasmObjectFile::ReadContext &Ctx) {
}
static int64_t readFloat64(WasmObjectFile::ReadContext &Ctx) {
if (Ctx.Ptr + 8 > Ctx.End)
report_fatal_error("EOF while reading float64");
int64_t Result = 0;
memcpy(&Result, Ctx.Ptr, sizeof(Result));
Ctx.Ptr += sizeof(Result);