Print SHA1 of the patch if bsdiff fails with data error

This will help us to identify the patch corruption.

Meanwhile fix a wrong size parameter passed to bspatch.
(patch->data.size() into patch->data.size() - patch_offset).

Also remove the only usage of "ApplyBSDiffPatchMem()" and inline its
Sink function for simplicity.

Bug: 37855643
Test: Prints SHA1 for corrupted patch in imgdiff_test.
Change-Id: Ibf2db8c08b0ded1409bb7c91a3547a6bf99c601d
This commit is contained in:
Tianjie Xu
2017-05-15 12:32:33 -07:00
parent 7cb1b79673
commit ce5fa5e538
4 changed files with 71 additions and 22 deletions
@@ -69,8 +69,6 @@ int SaveFileContents(const char* filename, const FileContents* file);
void ShowBSDiffLicense();
int ApplyBSDiffPatch(const unsigned char* old_data, size_t old_size, const Value* patch,
size_t patch_offset, SinkFn sink, SHA_CTX* ctx);
int ApplyBSDiffPatchMem(const unsigned char* old_data, size_t old_size, const Value* patch,
size_t patch_offset, std::vector<unsigned char>* new_data);
// imgpatch.cpp
int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value* patch, SinkFn sink,