diff options
Diffstat (limited to '')
-rw-r--r-- | applypatch/imgdiff.cpp | 4 | ||||
-rw-r--r-- | applypatch/imgpatch.cpp | 1 | ||||
-rw-r--r-- | applypatch/include/applypatch/imgdiff_image.h | 3 |
3 files changed, 5 insertions, 3 deletions
diff --git a/applypatch/imgdiff.cpp b/applypatch/imgdiff.cpp index 674cc2b16..415d95f14 100644 --- a/applypatch/imgdiff.cpp +++ b/applypatch/imgdiff.cpp @@ -462,12 +462,12 @@ PatchChunk::PatchChunk(const ImageChunk& tgt) target_len_(tgt.GetRawDataLength()), target_uncompressed_len_(tgt.DataLengthForPatch()), target_compress_level_(tgt.GetCompressLevel()), - data_(tgt.DataForPatch(), tgt.DataForPatch() + tgt.DataLengthForPatch()) {} + data_(tgt.GetRawData(), tgt.GetRawData() + tgt.GetRawDataLength()) {} // Return true if raw data is smaller than the patch size. bool PatchChunk::RawDataIsSmaller(const ImageChunk& tgt, size_t patch_size) { size_t target_len = tgt.GetRawDataLength(); - return (tgt.GetType() == CHUNK_NORMAL && (target_len <= 160 || target_len < patch_size)); + return target_len < patch_size || (tgt.GetType() == CHUNK_NORMAL && target_len <= 160); } void PatchChunk::UpdateSourceOffset(const SortedRangeSet& src_range) { diff --git a/applypatch/imgpatch.cpp b/applypatch/imgpatch.cpp index c4c2707fb..2f8f4851d 100644 --- a/applypatch/imgpatch.cpp +++ b/applypatch/imgpatch.cpp @@ -54,6 +54,7 @@ static bool ApplyBSDiffPatchAndStreamOutput(const uint8_t* src_data, size_t src_ const Value& patch, size_t patch_offset, const char* deflate_header, SinkFn sink) { size_t expected_target_length = static_cast<size_t>(Read8(deflate_header + 32)); + CHECK_GT(expected_target_length, 0); int level = Read4(deflate_header + 40); int method = Read4(deflate_header + 44); int window_bits = Read4(deflate_header + 48); diff --git a/applypatch/include/applypatch/imgdiff_image.h b/applypatch/include/applypatch/imgdiff_image.h index 084807237..671605160 100644 --- a/applypatch/include/applypatch/imgdiff_image.h +++ b/applypatch/include/applypatch/imgdiff_image.h @@ -44,6 +44,8 @@ class ImageChunk { int GetType() const { return type_; } + + const uint8_t* GetRawData() const; size_t GetRawDataLength() const { return raw_data_len_; } @@ -99,7 +101,6 @@ class ImageChunk { bsdiff::SuffixArrayIndexInterface** bsdiff_cache); private: - const uint8_t* GetRawData() const; bool TryReconstruction(int level); int type_; // CHUNK_NORMAL, CHUNK_DEFLATE, CHUNK_RAW |