-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Sort files list in FileDirectory::loadAll() #3657
Conversation
This lets us assemble classes.dex in a reproducible manner. Test: apktool d test.apk > /dev/null apktool b test > /dev/null sha1sum test/build/apk/classes.dex apktool -f d test.apk > /dev/null apktool b test > /dev/null sha1sum test/build/apk/classes.dex
Do you have a sample application that isn't the same?
Running a few of my samples through and its the same every time. |
Here you go. |
What hash do you get with that sample?
|
|
Thanks. I don't see anything dangerous with this merge, I'm just trying to understand how this is happening and I can't replicate. |
Also, with the following diff applied: diff --git a/brut.j.dir/src/main/java/brut/directory/FileDirectory.java b/brut.j.dir/src/main/java/brut/directory/FileDirectory.java
index fd6e88a5..0981693f 100644
--- a/brut.j.dir/src/main/java/brut/directory/FileDirectory.java
+++ b/brut.j.dir/src/main/java/brut/directory/FileDirectory.java
@@ -109,8 +109,21 @@ public class FileDirectory extends AbstractDirectory {
mDirs = new LinkedHashMap<>();
File[] files = getDir().listFiles();
+
+ for (File file : files) {
+ if (file.isFile()) {
+ System.out.println("[pre-sort] " + file.getName());
+ }
+ }
+
Arrays.sort(files, Comparator.comparing(f -> f.getName()));
+ for (File file : files) {
+ if (file.isFile()) {
+ System.out.println("[post-sort] " + file.getName());
+ }
+ }
+
for (File file : files) {
if (file.isFile()) {
mFiles.add(file.getName());
(diff between both executions) --- a 2024-08-07 13:02:48.910824438 +0200
+++ b 2024-08-07 13:02:53.798824914 +0200
@@ -1,6 +1,6 @@
-[pre-sort] IBase$Stub.smali
-[pre-sort] IBase$Proxy.smali
[pre-sort] DebugInfo$Architecture.smali
+[pre-sort] IBase$Proxy.smali
+[pre-sort] IBase$Stub.smali
[pre-sort] DebugInfo.smali
[pre-sort] IBase.smali
[post-sort] DebugInfo$Architecture.smali
@@ -22,8 +22,8 @@
[pre-sort] PowerOffAlarmDialog$2.smali
[pre-sort] PowerOffAlarmDialog$ShutDownReceiver.smali
[pre-sort] PowerOffAlarmDialog.smali
-[pre-sort] PowerOffAlarmUtils.smali
[pre-sort] PowerOffAlarmPersistData.smali
+[pre-sort] PowerOffAlarmUtils.smali
[pre-sort] R$drawable.smali
[pre-sort] R$id.smali
[pre-sort] R$layout.smali |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - don't see a downside.
hmm, I noticed that this only appears to happen when I do it inside tmpfs. If I repeat the same steps inside my $HOME, the sha1sums are always identical. |
Well thats odd. I sure don't have enough knowledge on filesystems to even begin to understand why that is. |
This lets us assemble classes.dex in a reproducible manner.
Test:
apktool d test.apk > /dev/null
apktool b test > /dev/null
sha1sum test/build/apk/classes.dex
apktool -f d test.apk > /dev/null
apktool b test > /dev/null
sha1sum test/build/apk/classes.dex