Skip to content

Commit

Permalink
Apply file permissions to valid entries only
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Aug 29, 2024
1 parent c8002af commit 78a225e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/com/reandroid/archive/Archive.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.reandroid.utils.collection.ArrayIterator;
import com.reandroid.utils.collection.CollectionUtil;
import com.reandroid.utils.collection.ComputeIterator;
import com.reandroid.utils.io.FilePermissions;
import com.reandroid.utils.io.FileUtil;
import com.reandroid.utils.io.IOUtil;

Expand Down Expand Up @@ -182,9 +183,11 @@ public void extract(File file, ArchiveEntry archiveEntry, APKLogger logger) thro
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private void applyAttributes(ArchiveEntry archiveEntry, File file) {
CentralEntryHeader ceh = archiveEntry.getCentralEntryHeader();
ceh.getFilePermissions().apply(file);
long time = Archive.dosToJavaDate(ceh.getDosTime()).getTime();
FilePermissions permissions = archiveEntry.getFilePermissions();
if(permissions.get() != 0) {
permissions.apply(file);
}
long time = Archive.dosToJavaDate(archiveEntry.getDosTime()).getTime();
file.setLastModified(time);
}
abstract void extractStored(File file, ArchiveEntry archiveEntry) throws IOException;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/reandroid/archive/ArchiveEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.reandroid.archive.block.CentralEntryHeader;
import com.reandroid.archive.block.LocalFileHeader;
import com.reandroid.utils.HexUtil;
import com.reandroid.utils.io.FilePermissions;

public class ArchiveEntry {
private final LocalFileHeader localFileHeader;
Expand Down Expand Up @@ -91,6 +92,9 @@ public boolean isFile() {
public boolean isDirectory() {
return this.getName().endsWith("/");
}
public FilePermissions getFilePermissions() {
return getCentralEntryHeader().getFilePermissions();
}
public CentralEntryHeader getCentralEntryHeader(){
CentralEntryHeader ceh = localFileHeader.getCentralEntryHeader();
if(ceh == null){
Expand Down

0 comments on commit 78a225e

Please sign in to comment.