From 31f8cc84cfc14eecdd96c6ca8eb411aa8610db22 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 15 Jun 2016 11:56:42 -0700 Subject: Check the results from applypatch Check the results from applypatch in PerformCommandDiff; and abort the update on failure. Bug:29339536 Change-Id: I5087d79ba532b54250f4c17560524255c8a4fabc --- updater/blockimg.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp index f7955566d..a80180a9a 100644 --- a/updater/blockimg.cpp +++ b/updater/blockimg.cpp @@ -1267,11 +1267,17 @@ static int PerformCommandDiff(CommandParameters& params) { } if (params.cmdname[0] == 'i') { // imgdiff - ApplyImagePatch(params.buffer.data(), blocks * BLOCKSIZE, &patch_value, - &RangeSinkWrite, &rss, nullptr, nullptr); + if (ApplyImagePatch(params.buffer.data(), blocks * BLOCKSIZE, &patch_value, + &RangeSinkWrite, &rss, nullptr, nullptr) != 0) { + fprintf(stderr, "Failed to apply image patch.\n"); + return -1; + } } else { - ApplyBSDiffPatch(params.buffer.data(), blocks * BLOCKSIZE, &patch_value, 0, - &RangeSinkWrite, &rss, nullptr); + if (ApplyBSDiffPatch(params.buffer.data(), blocks * BLOCKSIZE, &patch_value, + 0, &RangeSinkWrite, &rss, nullptr) != 0) { + fprintf(stderr, "Failed to apply bsdiff patch.\n"); + return -1; + } } // We expect the output of the patcher to fill the tgt ranges exactly. -- cgit v1.2.3