From abba55b4c52cc347e8806ba833645f150f2965ce Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 17 Jul 2015 18:11:12 -0700 Subject: applypatch: Support flash mode. We may carry a full copy of recovery image in the /system, and use /system/bin/install-recovery.sh to install the recovery. This CL adds support to flash the recovery partition with the given image. Bug: 22641135 Change-Id: I7a275b62fdd1bf41f97f6aab62d0200f7dae5aa1 (cherry picked from commit 68c5a6796737bb583a8bdfa4c9cd9c7f12ef4276) --- applypatch/applypatch.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'applypatch/applypatch.h') diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index edec84812..415bc1b3c 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -48,6 +48,8 @@ size_t FreeSpaceForFile(const char* filename); int CacheSizeCheck(size_t bytes); int ParseSha1(const char* str, uint8_t* digest); +int applypatch_flash(const char* source_filename, const char* target_filename, + const char* target_sha1_str, size_t target_size); int applypatch(const char* source_filename, const char* target_filename, const char* target_sha1_str, -- cgit v1.2.3 From c48cb5e5972bbeb1cacbe37b80a3e9f8003b54b7 Mon Sep 17 00:00:00 2001 From: Sen Jiang Date: Thu, 4 Feb 2016 16:23:21 +0800 Subject: Switch from mincrypt to BoringSSL in applypatch and updater. Bug: 18790686 Change-Id: I7d2136fb39b2266f5ae5be24819c617b08a6c21e --- applypatch/applypatch.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'applypatch/applypatch.h') diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index 415bc1b3c..e0df104b5 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -18,16 +18,16 @@ #define _APPLYPATCH_H #include -#include "mincrypt/sha.h" +#include "openssl/sha.h" #include "edify/expr.h" typedef struct _Patch { - uint8_t sha1[SHA_DIGEST_SIZE]; + uint8_t sha1[SHA_DIGEST_LENGTH]; const char* patch_filename; } Patch; typedef struct _FileContents { - uint8_t sha1[SHA_DIGEST_SIZE]; + uint8_t sha1[SHA_DIGEST_LENGTH]; unsigned char* data; ssize_t size; struct stat st; -- cgit v1.2.3 From d483c20a7e459bd2f8e5e134355a923282175977 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 3 Feb 2016 17:08:52 -0800 Subject: applypatch: fix memory leaks reported by static analysis. Bug: 26906416 Change-Id: I163df5a8f3abda3ba5d4ed81dfc8567054eceb27 --- applypatch/applypatch.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'applypatch/applypatch.h') diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index e0df104b5..14fb490ba 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -18,6 +18,9 @@ #define _APPLYPATCH_H #include + +#include + #include "openssl/sha.h" #include "edify/expr.h" @@ -68,22 +71,22 @@ void FreeFileContents(FileContents* file); int FindMatchingPatch(uint8_t* sha1, char* const * const patch_sha1_str, int num_patches); -// bsdiff.c +// bsdiff.cpp void ShowBSDiffLicense(); int ApplyBSDiffPatch(const unsigned char* old_data, ssize_t old_size, const Value* patch, ssize_t patch_offset, SinkFn sink, void* token, SHA_CTX* ctx); int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size, const Value* patch, ssize_t patch_offset, - unsigned char** new_data, ssize_t* new_size); + std::vector* new_data); -// imgpatch.c +// imgpatch.cpp int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size, const Value* patch, SinkFn sink, void* token, SHA_CTX* ctx, const Value* bonus_data); -// freecache.c +// freecache.cpp int MakeFreeSpaceOnCache(size_t bytes_needed); #endif -- cgit v1.2.3 From 1c522df25f9524eaa0273538b3de0b9ad1b8fcea Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 10 Feb 2016 16:41:10 -0800 Subject: applypatch: use vector to store data in FileContents. Cherry pick this patch because it fixes the problem that a newed Value is released by free(). Bug: 26906416 Change-Id: Ib53b445cd415a1ed5e95733fbc4073f9ef4dbc43 (cherry picked from commit d6c93afcc28cc65217ba65eeb646009c4f15a2ad) --- applypatch/applypatch.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'applypatch/applypatch.h') diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h index 14fb490ba..f392c5534 100644 --- a/applypatch/applypatch.h +++ b/applypatch/applypatch.h @@ -24,17 +24,11 @@ #include "openssl/sha.h" #include "edify/expr.h" -typedef struct _Patch { +struct FileContents { uint8_t sha1[SHA_DIGEST_LENGTH]; - const char* patch_filename; -} Patch; - -typedef struct _FileContents { - uint8_t sha1[SHA_DIGEST_LENGTH]; - unsigned char* data; - ssize_t size; + std::vector data; struct stat st; -} FileContents; +}; // When there isn't enough room on the target filesystem to hold the // patched version of the file, we copy the original here and delete -- cgit v1.2.3