Minor refactoring to accomodate changes in Google's internal code tree.
git-svn-id: https://snappy.googlecode.com/svn/trunk@57 03e5f5b5-db94-4691-08a0-1a8bf15f6143
This commit is contained in:
@@ -68,5 +68,4 @@ char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) {
|
|||||||
return dest_;
|
return dest_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class Sink {
|
|||||||
// The default implementation always returns the scratch buffer.
|
// The default implementation always returns the scratch buffer.
|
||||||
virtual char* GetAppendBuffer(size_t length, char* scratch);
|
virtual char* GetAppendBuffer(size_t length, char* scratch);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// No copying
|
// No copying
|
||||||
Sink(const Sink&);
|
Sink(const Sink&);
|
||||||
|
|||||||
13
snappy.cc
13
snappy.cc
@@ -805,6 +805,15 @@ static bool InternalUncompress(Source* r,
|
|||||||
SnappyDecompressor decompressor(r);
|
SnappyDecompressor decompressor(r);
|
||||||
uint32 uncompressed_len = 0;
|
uint32 uncompressed_len = 0;
|
||||||
if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false;
|
if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false;
|
||||||
|
return InternalUncompressAllTags(
|
||||||
|
&decompressor, writer, uncompressed_len, max_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Writer>
|
||||||
|
static bool InternalUncompressAllTags(SnappyDecompressor* decompressor,
|
||||||
|
Writer* writer,
|
||||||
|
uint32 uncompressed_len,
|
||||||
|
uint32 max_len) {
|
||||||
// Protect against possible DoS attack
|
// Protect against possible DoS attack
|
||||||
if (static_cast<uint64>(uncompressed_len) > max_len) {
|
if (static_cast<uint64>(uncompressed_len) > max_len) {
|
||||||
return false;
|
return false;
|
||||||
@@ -813,8 +822,8 @@ static bool InternalUncompress(Source* r,
|
|||||||
writer->SetExpectedLength(uncompressed_len);
|
writer->SetExpectedLength(uncompressed_len);
|
||||||
|
|
||||||
// Process the entire input
|
// Process the entire input
|
||||||
decompressor.DecompressAllTags(writer);
|
decompressor->DecompressAllTags(writer);
|
||||||
return (decompressor.eof() && writer->CheckLength());
|
return (decompressor->eof() && writer->CheckLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetUncompressedLength(Source* source, uint32* result) {
|
bool GetUncompressedLength(Source* source, uint32* result) {
|
||||||
|
|||||||
Reference in New Issue
Block a user