Fix A/B update fail for 32-bit devices
Type 'off_t' in this project is eight bytes no matter the device
is 32-bit or 64-bit, because -D_FILE_OFFSET_BITS=64 is specified
in Android.mk. See the following link for more details about
_FILE_OFFSET_BITS:
https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
Current check of "an off_t value > std::numeric_limits<long>::max()"
might fail on a 32-bit device, because off_t is eight bytes while long
is four bytes. The check should be removed as the underlying
fseek/lseek takes an off_t instead of a long value, which already
returns EOVERFLOW if the offset cannot be represented in an off_t.
A new assertion is also added in the public file_interface.h header,
to check all clients set _FILE_OFFSET_BITS=64. Otherwise, the mismatch
between the interface/implementation will have problem at runtime.
Bug: 71775459
Change-Id: Ie683b293ebbf3cb36b0f1d1f3033711df686174d
Test: A/B update successfully after we apply this patch.
Test: Removes -D_FILE_OFFSET_BITS=64 in Android.mk, `mmm external/bsdiff`,
checks the assertion fails.
Loading
Please sign in to comment