From 391bb7bb924a1b0a7990a8a7e2875ee94387e73d Mon Sep 17 00:00:00 2001 From: Jinguang Dong Date: Wed, 26 Apr 2017 10:40:45 +0800 Subject: applypatch: Add determine the return value of ApplyDiffPatch and capture the error flow. Construct ota package which is bsdiff exception scene ,then do simulation test, native code can not capture exception scenes. Test: recovery_component_test Test: Apply an bsdiff exception scene ota package. Change-Id: Icd9f6eac78739bd35c74b9fcaaf8154335d680a5 --- applypatch/imgpatch.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/applypatch/imgpatch.cpp b/applypatch/imgpatch.cpp index 7d8b7361c..3d905f7b4 100644 --- a/applypatch/imgpatch.cpp +++ b/applypatch/imgpatch.cpp @@ -100,7 +100,10 @@ int ApplyImagePatch(const unsigned char* old_data, size_t old_size, const Value* printf("source data too short\n"); return -1; } - ApplyBSDiffPatch(old_data + src_start, src_len, patch, patch_offset, sink, ctx); + if (ApplyBSDiffPatch(old_data + src_start, src_len, patch, patch_offset, sink, ctx) != 0) { + printf("Failed to apply bsdiff patch.\n"); + return -1; + } } else if (type == CHUNK_RAW) { const char* raw_header = &patch->data[pos]; pos += 4; -- cgit v1.2.3