From 6991b2045d3235de027382921ce12e802fb7eac1 Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 14 Aug 2020 01:50:41 -0700 Subject: [PATCH] Set `valid` to false if `size` is bogus This is to prevent callers from parsing bogus sizes. If they listen to the -1 sentinel value, at least... --- desktop_version/src/BinaryBlob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop_version/src/BinaryBlob.cpp b/desktop_version/src/BinaryBlob.cpp index 1ddea512..18f2fa2c 100644 --- a/desktop_version/src/BinaryBlob.cpp +++ b/desktop_version/src/BinaryBlob.cpp @@ -98,10 +98,12 @@ bool binaryBlob::unPackBinary(const char* name) } if (m_headers[i].size < 1) { + m_headers[i].valid = false; continue; /* Must be nonzero and positive */ } if ((offset + m_headers[i].size) > size) { + m_headers[i].valid = false; continue; /* Bogus size value */ }