Bug 1587112 - Make asserts in StartupCache::LoadArchive explicit r=njn

There is no behavior change here - these asserts were previously being hit
inside the operator+ of RangedPtr, but this makes them explicit.

Differential Revision: https://phabricator.services.mozilla.com/D49985

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Doug Thayer 2019-10-22 03:15:18 +00:00
Родитель ca34a940cf
Коммит cc57ad9bcb
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -283,7 +283,8 @@ Result<Ok, nsresult> StartupCache::LoadArchive() {
headerSize = LittleEndian::readUint32(data.get()); headerSize = LittleEndian::readUint32(data.get());
data += sizeof(headerSize); data += sizeof(headerSize);
if (data + headerSize > end) { if (headerSize > end - data) {
MOZ_ASSERT(false, "StartupCache file is corrupt.");
return Err(NS_ERROR_UNEXPECTED); return Err(NS_ERROR_UNEXPECTED);
} }
@ -312,7 +313,8 @@ Result<Ok, nsresult> StartupCache::LoadArchive() {
buf.codeUint32(uncompressedSize); buf.codeUint32(uncompressedSize);
buf.codeString(key); buf.codeString(key);
if (data + offset + compressedSize > end) { if (offset + compressedSize > end - data) {
MOZ_ASSERT(false, "StartupCache file is corrupt.");
return Err(NS_ERROR_UNEXPECTED); return Err(NS_ERROR_UNEXPECTED);
} }