6 Commits
Author SHA1 Message Date
Alex Deymo 188fa33f3f Added more unittests for invalid patch formats.
This adds new unittests to cover more error cases in the parsing logic.

Bug: None
Test: Added more unittests.

Change-Id: I897ae5e966fb6777d047855a72ff0a8489f4711f
2018-03-21 14:28:39 +01:00
Alex Deymo 7c4bb57f87 Handle more invalid patch header cases.
Added more unittests for checking invalid headers.

Bug: chromium:822821
Test: Added unittests
Change-Id: I649674c41f00395dbf63f53e2576f7b7b61116c3
2018-03-19 20:27:04 +01:00
Tianjie Xu 1f1cdb2b6b Add an argument parser in bsdiff
Add a parser of format, type and quality in the bsdiff main function.
This allow the bsdiff binary to choose between the BSDFF40|BSDF2 patch
format and compress the patch with desired algorithms.

Bug: 34220646
Test: unittest pass; generate brotli compressed patches with bsdiff
binary
Change-Id: Ia4f7941e4eca7e6047e2749315127d1cf4a988ee
2018-01-18 12:32:09 -08:00
Tianjie Xu d4875cd320 Fix the bspatch failure on an empty brotli stream
When we close the BrotliDecompressor, we check for
BrotliDecoderIsFinished(). This function may return false if we never
call BrotliDecoderDecompressStream(), leading to a failure in bspatch
in case of an empty brotli stream.

This CL fixes the issue by checking BrotliDecoderIsUsed() along with
IsFinished(). Since we have the compressed stream and the precomputed
uncompressed size in the patch; we need these checks to avoid unexpected
size mismatch.

Bug: 69472150
Test: unittest pass
Change-Id: Icf7b324836fa59fd3111ba91b03622215a0c8f5f
2017-11-17 16:54:05 -08:00
Tianjie Xu b4cba64184 Implement a new bsdiff format
Add a new BSDF2 format that allows compression of ctrl/diff/extra streams
with different algorithms. The compression algorithm supported for now is
bz2 and brotli. This new format is similar to the legacy "BSDIFF40" format
except for the magic headers.

File format:
0       8    magic header
8       8    X
16      8    Y
24      8    new_file_size
32      X    compressed control block
32+X    Y    compressed diff block
32+X+Y  ???  compressed extra block

The magic header for BSDF2 format:
0 5 BSDF2
5 1 compressed type for control stream
6 1 compressed type for diff stream
7 1 compressed type for extra stream

Bug: 34220646
Test: unittest pass
Change-Id: I6eb0867e88476dbc4a4b7be609783f8c8a0a41cd
2017-11-16 14:46:37 -08:00
Tianjie Xu 6528812247 Add an interface for bspatch reader
Add a wrapper class to separate the patch read from data stream
decompression. Therefore, bspatch will be able to process the patch
that is compressed with various tools.

Test: unittest pass
Change-Id: I5214e0451bde80366e8a70b960703afb2b2a7d97
2017-10-26 14:50:34 -07:00