forked from OSchip/llvm-project
[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:
parent
c807ce0ee4
commit
e3d6b9786e
|
@ -82,6 +82,8 @@ static uint32_t readUint32(WasmObjectFile::ReadContext &Ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t readFloat32(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;
|
int32_t Result = 0;
|
||||||
memcpy(&Result, Ctx.Ptr, sizeof(Result));
|
memcpy(&Result, Ctx.Ptr, sizeof(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) {
|
static int64_t readFloat64(WasmObjectFile::ReadContext &Ctx) {
|
||||||
|
if (Ctx.Ptr + 8 > Ctx.End)
|
||||||
|
report_fatal_error("EOF while reading float64");
|
||||||
int64_t Result = 0;
|
int64_t Result = 0;
|
||||||
memcpy(&Result, Ctx.Ptr, sizeof(Result));
|
memcpy(&Result, Ctx.Ptr, sizeof(Result));
|
||||||
Ctx.Ptr += sizeof(Result);
|
Ctx.Ptr += sizeof(Result);
|
||||||
|
|
Loading…
Reference in New Issue