Bug 1167888 - better string length check in nsZipArchive::BuildFileList, r=smaug

This commit is contained in:
Andrea Marchesini 2015-06-04 15:04:10 +01:00
parent 11447ad068
commit 006c22233c

View File

@ -644,8 +644,13 @@ MOZ_WIN_MEM_TRY_BEGIN
if (!centralOffset)
return NS_ERROR_FILE_CORRUPTED;
//-- Read the central directory headers
buf = startp + centralOffset;
// avoid overflow of startp + centralOffset.
if (buf < startp)
return NS_ERROR_FILE_CORRUPTED;
//-- Read the central directory headers
uint32_t sig = 0;
while (buf + int32_t(sizeof(uint32_t)) <= endp &&
(sig = xtolong(buf)) == CENTRALSIG) {