Age | Commit message (Collapse) | Author |
|
Test: treehugger
Change-Id: I032e01c62ca7f188f02c584af20ebb026a5334dd
|
|
oldpos is a signed integer and an invalid input can cause integer
overflow. This CL makes sure the interger overflow doesn't happen.
The error message was:
../../../../../../../tmp/portage/dev-util/bsdiff-9999/work/bsdiff-9999/platform2/bsdiff/bspatch.cc:366:12: runtime error: signed integer overflow: 251 + 9223372036854775807 cannot be represented in type 'long'
Bug: crbug.com/950591
Test: cros_fuzz --board=amd64-generic reproduce --fuzzer bspatch_fuzzer --testcase ~/trunk/clusterfuzz-testcase-bspatch_fuzzer-5689939906920448 --package bsdiff --build-type ubsan
Change-Id: If1253483bc073cfb08867b531121d835078544bb
|
|
We need to be able to turn off the logging at runtime. When performing fuzz
testing, the input data is mostly invalid. But the invalid input data causes all
the error logs in the output which is noisy, inefficient, and not
necessary. More information can be found in:
https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/getting_started.md#disable-noisy-error-message-logging
One option to turn off the logging at runtime is:
std::cerr.setstate(std::ios_base::failbit);
which works but not when we are doing fprintf to stderr. Another option
is in the lines of the following:
freopen("/dev/null", "w", stderr);
But, this seem to disable everything even useful needed logs.
This patch, changes all codes (except in bsdiff_main.cc) that logs using
fprintf() and perror() to the new uniform form of logging (defined in
logging.h). This new logging alternative allows universal manipulation of the
logging if necessary.
Bug: none
Test: unittests pass
Change-Id: I42bb3e5856c5c215dd82925ccdca44556124655d
|
|
uint64_t and similar types are defined in stdint.h, and size_t is
defined in stddef.h. While these headers are included virtually
everywhere anyways we should include what we use, specially in public
headers.
Bug: None
Test: still compiles.
Change-Id: I26846be960bf9c989372a05e9c4369caf02888cd
|
|
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
|
|
This prevents accidentally including a header file from another project
that happens to have the same name.
Test: `make checkbuild`; emerge-${BOARD} bsdiff
Bug: None
Change-Id: I8af132ed388738c30a8e3d7434de70b1e9d2f924
|
|
The Makefile didn't build libbspatch and libbsdiff. This patch includes
those libraries in the Makefile and moves the header files exposed by
those to an include/bsdiff subdirectory following the Android
convention so calling program can include "bsdiff/bspatch.h" avoiding
any collision with other libraries.
The Android.mk is updated to export the new include path while keeping
the old style until calling programs are updated.
The new Makefile allows Chromium OS to build the new libraries.
Bug: None
Test: FEATURES=test emerge-link bsdiff; sudo emerge bsdiff
Test: mmma external/bsdiff
Change-Id: I2ea9251eb224e9418fe236e4c4c9c5621853f590
|
|
It accepts old and new filenames with extents and patch data and size.
Bug: 26982501
Test: mma
Change-Id: I812fe7441fe2ae768bbfc48c65c097af991c105b
|
|
bspatch is used as a library now, it can't just exit on errors.
Bug: 29058789
Test: mma
Change-Id: I226574a534027d9dc8e5801bc71104dc6d1a410c
|
|
Renamed existing MemoryFile to BufferFile, and added a read only
MemoryFile to provide file interface to read file data already in
memory without extra copy (extra memory usage).
Added write only SinkFile to provide sink function support used in
applypatch. It will enable imgpatch the ability to stream output.
Test: mma
Bug: 26982501
Change-Id: I025ce4064c9f46623dd73f24d30e21e88f08a292
|
|
Clearing |buffer_| still actually makes sense because MemoryFile::Close()
is called twice: once explicitly from bspatch to check if Close()
succeeded, once from destructor to ensure that everything is closed. And
if we don't clear |buffer_|, on the second Close(), it will try to write
|buffer_| to |file_| again, and if |file_| is an ExtentsFile, it will
simply return true and set |bytes_written| to 0 on Write() because all
the extents are already written, now WriteAll() became an infinite
loop.
Although returning false if written is 0 in WriteAll() will fix this, but
I think we should not write the same buffer again in the first place.
Test: call bspatch with extents
Bug: 25773600
Change-Id: If3bddcc6e8ca6751c422c066e5b8b02f91086ed5
|
|
Now that update_engine no longer uses minor version 1, old file and
new file are always different in the device, so we can write the
output to disk right away to save memory.
The old behavior is still kept if the new file is overlapping with the
old file for paycheck.py usage.
Test: bsdiff_unittest
Test: apply a 3M patch overwriting old file, uses 25M memory.
Test: apply a 3M patch not overwriting old file, uses 9M memory.
Bug: 25773600
Change-Id: Ic289c9bcc6f1810d0f222a9a4241c05756084b1c
|
|
bspatch should add diff block and old file.
Fix crash on free(new_buf).
open() in bionic needs mode to be set if O_CREAT.
Fix typo in Seek().
Wrong GetSize() for regular file.
Bug: 24478450
Test: Delta update passes filesystem verification on target partition.
Change-Id: Ie53b7cf2b7467fb2cf78762d41e7f65674afa969
|
|
With the implementation of the ExtentsFile, we can now use the
FileInterface from bspatch to read and write files. This patch
re-enables the extent argument support and adds unittests for the
argument parsing.
Bug: 24478450
Test: make all test && ./unittest
Change-Id: If6837f250df10c24d3ff96f7ad8f0e0d98126788
|
|
This patch attempts to uniform the format on bspatch before we land
further changes there.
Bug: 24478450
Test: make all test && ./unittest
Change-Id: I45ec3d45ab4b081bddef1ac7f5df35ac7e6e554c
|
|
To help refactoring the FILE* access behind an interface and better
integrate with unittest code, this patch moves the C sources to C++.
Minor changes to make this conform to C++ were included.
Bug: 24478450
Test: `make all test && ./unittests`; mm
Change-Id: I27d7fb0660efc18ea0cb84ff544c9dd9c4803050
|