Bug 1675465 - Add DIAGNOSTIC_ASSERT in nsJARInputStream::Read r=jstutte

We want to make sure we don't accidentally read more than the size of the file.

Differential Revision: https://phabricator.services.mozilla.com/D96006
This commit is contained in:
Valentin Gosu 2020-11-05 12:18:39 +00:00
Родитель 2190dfaf69
Коммит 0c6e62ade6
1 изменённых файлов: 2 добавлений и 0 удалений

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

@ -220,6 +220,8 @@ nsJARInputStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytesRead) {
case MODE_COPY:
if (mFd) {
MOZ_DIAGNOSTIC_ASSERT(mOutSize >= mZs.total_out,
"Did we read more than expected?");
uint32_t count = std::min(aCount, mOutSize - uint32_t(mZs.total_out));
if (count) {
memcpy(aBuffer, mZs.next_in + mZs.total_out, count);