One function
EndOfCentralDirectoryRecord in erev0s/apkInspector
The author described this change as “update eocd parse bug at offset”. It counts as a record because the check below fails on the code as it stood at 4d26bfa47 and passes on 7a203a892, with nothing else changed between the two runs.
Projecterev0s/apkInspector
Fix saved2024-06-05
Sharing licenceApache-2.0 · LICENSE
Change size+6 −6
What the code was meant to do, written into the code itself as a docstring
A class to provide details about the end of central directory record.
The change
| 34 | 34 | signature_offset = -1 | |
| 35 | 35 | file_size = apk_file.seek(0, 2) | |
| 36 | 36 | while offset < file_size: | |
| 37 | - | position = file_size - offset - chunk_size | |
| 38 | - | if position < 0: | |
| 39 | - | position = 0 | |
| 37 | + | position = max(0, file_size - offset - chunk_size) | |
| 40 | 38 | apk_file.seek(position) | |
| 41 | 39 | chunk = apk_file.read(chunk_size) | |
| 42 | 40 | if not chunk: | |
| 43 | 41 | break | |
| 44 | - | signature_offset = chunk.rfind(b'\x50\x4b\x05\x06') # end of Central Directory File Header signature | |
| 42 | + | signature_offset = chunk.rfind(b'\x50\x4b\x05\x06') # EOCD signature | |
| 45 | 43 | if signature_offset != -1: | |
| 46 | 44 | eo_central_directory_offset = position + signature_offset | |
| 47 | - | break # Found End of central directory record (EOCD) signature | |
| 48 | - | offset += chunk_size | |
| 45 | + | break # Found EOCD signature | |
| 46 | + | # Adjust offset to overlap by 4 bytes | |
| 47 | + | offset += chunk_size - 4 | |
| 48 | + | ||
| 49 | 49 | if signature_offset == -1: | |
| 50 | 50 | raise ValueError("End of central directory record (EOCD) signature not found") | |
| 51 | 51 | apk_file.seek(eo_central_directory_offset) |
The check that tells the two apart
fail→pass·tests/test_base.py::ApkInspectorTestCase::test_find_eocd_at_offset_1026
Check file tests/test_base.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it4d26bfa473897446e32518d2a1faeb628aedc0af
Broken version dated2024-05-05
ModuleapkInspector.headers
Units changedEndOfCentralDirectoryRecord
Fingerprint5697e69585b0f70f
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.