mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 847479 - Add buffer length information when initializing a SeekableZStream. r=nfroyd
This commit is contained in:
parent
1ea119afac
commit
d55975357b
@ -131,7 +131,7 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
|
||||
}
|
||||
} else if (stream->GetType() == Zip::Stream::STORE) {
|
||||
SeekableZStream zStream;
|
||||
if (!zStream.Init(stream->GetBuffer())) {
|
||||
if (!zStream.Init(stream->GetBuffer(), stream->GetSize())) {
|
||||
log("Couldn't initialize SeekableZStream for %s", name);
|
||||
return NULL;
|
||||
}
|
||||
@ -353,7 +353,7 @@ MappableSeekableZStream::Create(const char *name, Zip *zip,
|
||||
if (pthread_mutex_init(&mappable->mutex, NULL))
|
||||
return NULL;
|
||||
|
||||
if (!mappable->zStream.Init(stream->GetBuffer()))
|
||||
if (!mappable->zStream.Init(stream->GetBuffer(), stream->GetSize()))
|
||||
return NULL;
|
||||
|
||||
mappable->buffer = _MappableBuffer::Create(name,
|
||||
|
@ -15,7 +15,7 @@
|
||||
#endif
|
||||
|
||||
bool
|
||||
SeekableZStream::Init(const void *buf)
|
||||
SeekableZStream::Init(const void *buf, size_t length)
|
||||
{
|
||||
const SeekableZStreamHeader *header = SeekableZStreamHeader::validate(buf);
|
||||
if (!header) {
|
||||
@ -35,7 +35,8 @@ SeekableZStream::Init(const void *buf)
|
||||
(chunkSize > 8 * PAGE_SIZE) ||
|
||||
(offsetTable.numElements() < 1) ||
|
||||
(lastChunkSize == 0) ||
|
||||
(lastChunkSize > chunkSize)) {
|
||||
(lastChunkSize > chunkSize) ||
|
||||
(length < totalSize)) {
|
||||
log("Malformed or broken seekable zstream");
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class SeekableZStream {
|
||||
public:
|
||||
/* Initialize from the given buffer. Returns whether initialization
|
||||
* succeeded (true) or failed (false). */
|
||||
bool Init(const void *buf);
|
||||
bool Init(const void *buf, size_t length);
|
||||
|
||||
/* Decompresses starting from the given chunk. The decompressed data is
|
||||
* stored at the given location. The given length, in bytes, indicates
|
||||
|
Loading…
Reference in New Issue
Block a user