summaryrefslogtreecommitdiffstats
path: root/applypatch/bspatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'applypatch/bspatch.c')
-rw-r--r--applypatch/bspatch.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/applypatch/bspatch.c b/applypatch/bspatch.c
index 2e80f81d0..b34ec2a88 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;
@@ -205,6 +203,11 @@ int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size,
ctrl[1] = offtin(buf+8);
ctrl[2] = offtin(buf+16);
+ if (ctrl[0] < 0 || ctrl[1] < 0) {
+ printf("corrupt patch (negative byte counts)\n");
+ return 1;
+ }
+
// Sanity check
if (newpos + ctrl[0] > *new_size) {
printf("corrupt patch (new file overrun)\n");