Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove extraneous virtual entry? #64

Open
obfusk opened this issue Nov 3, 2022 · 0 comments
Open

remove extraneous virtual entry? #64

obfusk opened this issue Nov 3, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request maybe Unsure whether this will be worked on

Comments

@obfusk
Copy link
Owner

obfusk commented Nov 3, 2022

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:
@obfusk obfusk added enhancement New feature or request wontfix This will not be worked on maybe Unsure whether this will be worked on labels Nov 3, 2022
@obfusk obfusk self-assigned this Nov 3, 2022
@obfusk obfusk removed the wontfix This will not be worked on label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maybe Unsure whether this will be worked on
Projects
None yet
Development

No branches or pull requests

1 participant