Bug 847479 - Add buffer length information when initializing a SeekableZStream. r=nfroyd

This commit is contained in:
Mike Hommey 2013-03-06 07:29:05 +01:00
parent 1ea119afac
commit d55975357b
3 changed files with 6 additions and 5 deletions

View File

@ -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,

View File

@ -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;
}

View File

@ -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