| Index: third_party/zlib/google/compression_utils.cc
|
| diff --git a/third_party/zlib/google/compression_utils.cc b/third_party/zlib/google/compression_utils.cc
|
| index 575aa12619ba0b05e974a5d79857e754b1c72194..477f97f293ac88802f6c210cda0227ba61e476d5 100644
|
| --- a/third_party/zlib/google/compression_utils.cc
|
| +++ b/third_party/zlib/google/compression_utils.cc
|
| @@ -114,17 +114,6 @@ int GzipUncompressHelper(Bytef* dest,
|
| return err;
|
| }
|
|
|
| -// Returns the uncompressed size from GZIP-compressed |compressed_data|.
|
| -uint32_t GetUncompressedSize(const std::string& compressed_data) {
|
| - // The uncompressed size is stored in the last 4 bytes of |input| in LE.
|
| - uint32_t size;
|
| - if (compressed_data.length() < sizeof(size))
|
| - return 0;
|
| - memcpy(&size, &compressed_data[compressed_data.length() - sizeof(size)],
|
| - sizeof(size));
|
| - return base::ByteSwapToLE32(size);
|
| -}
|
| -
|
| } // namespace
|
|
|
| namespace compression {
|
| @@ -162,4 +151,25 @@ bool GzipUncompress(const std::string& input, std::string* output) {
|
| return false;
|
| }
|
|
|
| +bool GzipUncompress(base::StringPiece input, base::StringPiece output) {
|
| + uLongf uncompressed_size = GetUncompressedSize(input);
|
| + if (uncompressed_size > output.size())
|
| + return false;
|
| + return GzipUncompressHelper(bit_cast<Bytef*>(output.data()),
|
| + &uncompressed_size,
|
| + bit_cast<const Bytef*>(input.data()),
|
| + static_cast<uLongf>(input.length())) == Z_OK;
|
| +}
|
| +
|
| +uint32_t GetUncompressedSize(base::StringPiece compressed_data) {
|
| + // The uncompressed size is stored in the last 4 bytes of |input| in LE.
|
| + uint32_t size;
|
| + if (compressed_data.length() < sizeof(size))
|
| + return 0;
|
| + memcpy(&size,
|
| + &compressed_data.data()[compressed_data.length() - sizeof(size)],
|
| + sizeof(size));
|
| + return base::ByteSwapToLE32(size);
|
| +}
|
| +
|
| } // namespace compression
|
|
|