Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.
This repository was archived by the owner on May 12, 2025. It is now read-only.

remove extraneous virtual entry? #64

Description

@obfusk

This affects compare when only the second APK is v1-signed with signflinger (see FAQ; reversing the arguments should make it work), but should not ever impact copy/patch to an unsigned APK.

We could remove it when it's presumably not supposed to be there; but I currently don't think we should do that automatically.

Maybe with a --remove-virtual-entry option?

Also, split off size/presence detection into detect_zfe()?

diff --git a/apksigcopier/__init__.py b/apksigcopier/__init__.py
index 90fc5e7..6c34427 100755
--- a/apksigcopier/__init__.py
+++ b/apksigcopier/__init__.py
@@ -325,6 +325,11 @@ def copy_apk(unsigned_apk: str, output_apk: str, *, zfe_size: Optional[int] = No
             if fhi.read(zfe_size) != zfe:
                 fho.write(zfe)
             fhi.seek(0)
+        else:
+            if fhi.read(28) == zipflinger_virtual_entry(30)[:28]:
+                fhi.read(int.from_bytes(fhi.read(2), "little"))
+            else:
+                fhi.seek(0)
         for info in sorted(infos, key=lambda info: info.header_offset):
             off_i = fhi.tell()
             if info.header_offset > off_i:

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestmaybeUnsure whether this will be worked on

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions