mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 730425 - Performa an additional range check in stream read. r=roc
This commit is contained in:
parent
0be0db4666
commit
2bb439b67e
@ -2160,7 +2160,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
|
||||
PRUint32 streamBlock = PRUint32(mStreamOffset/BLOCK_SIZE);
|
||||
PRUint32 offsetInStreamBlock =
|
||||
PRUint32(mStreamOffset - streamBlock*BLOCK_SIZE);
|
||||
PRInt32 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
PRInt64 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock);
|
||||
|
||||
if (mStreamLength >= 0) {
|
||||
// Don't try to read beyond the end of the stream
|
||||
@ -2169,7 +2169,9 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
|
||||
// Get out of here and return NS_OK
|
||||
break;
|
||||
}
|
||||
size = NS_MIN(size, PRInt32(bytesRemaining));
|
||||
size = NS_MIN(size, bytesRemaining);
|
||||
// Clamp size until 64-bit file size issues (bug 500784) are fixed.
|
||||
size = NS_MIN(size, PRInt64(PR_INT32_MAX));
|
||||
}
|
||||
|
||||
PRInt32 bytes;
|
||||
@ -2224,7 +2226,8 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
|
||||
gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now());
|
||||
|
||||
PRInt64 offset = cacheBlock*BLOCK_SIZE + offsetInStreamBlock;
|
||||
nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, size, &bytes);
|
||||
NS_ASSERTION(size >= 0 && size <= PR_INT32_MAX, "Size out of range.");
|
||||
nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, PRInt32(size), &bytes);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (count == 0)
|
||||
return rv;
|
||||
|
Loading…
Reference in New Issue
Block a user