diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2022-04-18 17:18:23 -0700 |
---|---|---|
committer | Kelvin Zhang <zhangkelvin@google.com> | 2022-04-18 17:18:23 -0700 |
commit | 3353fd4997cc5af9d759037afe648083eddcc8b7 (patch) | |
tree | 16a3fc37ea924893d22684c3e834c4522cdc624b | |
parent | 80be4157fe6c64bd5c25bc7edbcce1760e4a3758 (diff) | |
download | puffin-3353fd4997cc5af9d759037afe648083eddcc8b7.tar.gz |
Skip last incomplete gzip entry
Do not report as an error if last gzip entry is incomplete(missing
comment section or CRC32). We can still use the partially identified
deflate locations to perform diffing.
Test: th
Bug: 229655726
Change-Id: Ia0fe105a1d4cdb9c18b4622429ae6d2fe92448ef
-rw-r--r-- | src/utils.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils.cc b/src/utils.cc index b2666d3..23d8479 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -185,7 +185,7 @@ bool IsValidGzipHeader(const uint8_t* header, size_t size) { // 0 1 0x1F // 1 1 0x8B // 2 1 compression method (8 denotes deflate) - static const uint8_t magic[] = {0x1F, 0x8B, 8}; + static constexpr uint8_t magic[] = {0x1F, 0x8B, 8}; return size >= 10 && std::equal(std::begin(magic), std::end(magic), header); } } // namespace @@ -240,10 +240,10 @@ bool LocateDeflatesInGzip(const Buffer& data, vector<BitExtent>* deflates) { offset += compressed_size; // Ignore CRC32 and uncompressed size. - TEST_AND_RETURN_FALSE(offset + 8 <= data.size()); offset += 8; member_start = offset; - } while (IsValidGzipHeader(&data[member_start], data.size() - member_start)); + } while (member_start < data.size() && + IsValidGzipHeader(&data[member_start], data.size() - member_start)); return true; } |