aboutsummaryrefslogtreecommitdiffstats
path: root/applypatch
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2014-08-15 14:31:52 -0700
committerDoug Zongker <dougz@google.com>2014-08-19 16:53:39 -0700
commitbc7ffeda98a861e346c30c771d3258030f7fcf21 (patch)
treea435cfd2bd1b457bb2e45304b8e75cd2e1305831 /applypatch
parent2efc9d994ce59f9ebfc2290c2adc5d760e8939c2 (diff)
downloadbootable_recovery-bc7ffeda98a861e346c30c771d3258030f7fcf21.zip
bootable_recovery-bc7ffeda98a861e346c30c771d3258030f7fcf21.tar.gz
bootable_recovery-bc7ffeda98a861e346c30c771d3258030f7fcf21.tar.bz2
installer for new block OTA system
(Cherry-pick back from master.) Bug: 16984795 Change-Id: Ifa3d8345c5e2a0be86fb28faa080ca82592a96b4
Diffstat (limited to 'applypatch')
-rw-r--r--applypatch/applypatch.c6
-rw-r--r--applypatch/applypatch.h2
-rw-r--r--applypatch/bspatch.c4
-rw-r--r--applypatch/imgpatch.c4
4 files changed, 7 insertions, 9 deletions
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c
index 60e9e4a..bfb9440 100644
--- a/applypatch/applypatch.c
+++ b/applypatch/applypatch.c
@@ -32,7 +32,7 @@
#include "edify/expr.h"
static int LoadPartitionContents(const char* filename, FileContents* file);
-static ssize_t FileSink(unsigned char* data, ssize_t len, void* token);
+static ssize_t FileSink(const unsigned char* data, ssize_t len, void* token);
static int GenerateTarget(FileContents* source_file,
const Value* source_patch_value,
FileContents* copy_file,
@@ -599,7 +599,7 @@ int ShowLicenses() {
return 0;
}
-ssize_t FileSink(unsigned char* data, ssize_t len, void* token) {
+ssize_t FileSink(const unsigned char* data, ssize_t len, void* token) {
int fd = *(int *)token;
ssize_t done = 0;
ssize_t wrote;
@@ -620,7 +620,7 @@ typedef struct {
ssize_t pos;
} MemorySinkInfo;
-ssize_t MemorySink(unsigned char* data, ssize_t len, void* token) {
+ssize_t MemorySink(const unsigned char* data, ssize_t len, void* token) {
MemorySinkInfo* msi = (MemorySinkInfo*)token;
if (msi->size - msi->pos < len) {
return -1;
diff --git a/applypatch/applypatch.h b/applypatch/applypatch.h
index ee54c24..edec848 100644
--- a/applypatch/applypatch.h
+++ b/applypatch/applypatch.h
@@ -40,7 +40,7 @@ typedef struct _FileContents {
// and use it as the source instead.
#define CACHE_TEMP_SOURCE "/cache/saved.file"
-typedef ssize_t (*SinkFn)(unsigned char*, ssize_t, void*);
+typedef ssize_t (*SinkFn)(const unsigned char*, ssize_t, void*);
// applypatch.c
int ShowLicenses();
diff --git a/applypatch/bspatch.c b/applypatch/bspatch.c
index 1dc7ab1..b34ec2a 100644
--- a/applypatch/bspatch.c
+++ b/applypatch/bspatch.c
@@ -112,9 +112,7 @@ int ApplyBSDiffPatch(const unsigned char* old_data, ssize_t old_size,
printf("short write of output: %d (%s)\n", errno, strerror(errno));
return 1;
}
- if (ctx) {
- SHA_update(ctx, new_data, new_size);
- }
+ if (ctx) SHA_update(ctx, new_data, new_size);
free(new_data);
return 0;
diff --git a/applypatch/imgpatch.c b/applypatch/imgpatch.c
index af4d072..33c4487 100644
--- a/applypatch/imgpatch.c
+++ b/applypatch/imgpatch.c
@@ -95,7 +95,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size __unused,
printf("failed to read chunk %d raw data\n", i);
return -1;
}
- SHA_update(ctx, patch->data + pos, data_len);
+ if (ctx) SHA_update(ctx, patch->data + pos, data_len);
if (sink((unsigned char*)patch->data + pos,
data_len, token) != data_len) {
printf("failed to write chunk %d raw data\n", i);
@@ -217,7 +217,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size __unused,
(long)have);
return -1;
}
- SHA_update(ctx, temp_data, have);
+ if (ctx) SHA_update(ctx, temp_data, have);
} while (ret != Z_STREAM_END);
deflateEnd(&strm);