[llvm] r341216 - [Wasm] Add missing EOF checks for floats
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 31 07:54:01 PDT 2018
Author: jdevlieghere
Date: Fri Aug 31 07:54:01 2018
New Revision: 341216
URL: http://llvm.org/viewvc/llvm-project?rev=341216&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Object/WasmObjectFile.cpp
Modified: llvm/trunk/lib/Object/WasmObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WasmObjectFile.cpp?rev=341216&r1=341215&r2=341216&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp Fri Aug 31 07:54:01 2018
@@ -82,6 +82,8 @@ static uint32_t readUint32(WasmObjectFil
}
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(WasmObjectFil
}
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);
More information about the llvm-commits
mailing list