summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-08-31 14:54:01 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-08-31 14:54:01 +0000
commite3d6b9786e61c80a089a5812e7699dd18f0ebcc3 (patch)
tree7d0df28b7a83df6472a9e01161b959974a405034 /llvm/lib/Object/WasmObjectFile.cpp
parentc807ce0ee4b1609361bac4ee23ade1eeb8c64c84 (diff)
downloadbcm5719-llvm-e3d6b9786e61c80a089a5812e7699dd18f0ebcc3.tar.gz
bcm5719-llvm-e3d6b9786e61c80a089a5812e7699dd18f0ebcc3.zip
[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
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index f75dbfc3014..b8bc4712ec3 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -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);
OpenPOWER on IntegriCloud