Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ class DecompressActivity : SimpleActivity() {
zipInputStream.setPassword(password?.toCharArray())
}
val buffer = ByteArray(1024)
val foldersTimestamp = mutableListOf<Pair<File, LocalFileHeader>>()

zipInputStream.use {
while (true) {
val entry = zipInputStream.nextEntry ?: break
val filename = filename.substringBeforeLast(".")
val parent = "$destination/$filename"
val newPath = "$parent/${entry.fileName.trimEnd('/')}"
val outputFile = File(newPath)

if (!getDoesFilePathExist(parent)) {
if (!createDirectorySync(parent)) {
Expand All @@ -170,10 +172,14 @@ class DecompressActivity : SimpleActivity() {
}

if (entry.isDirectory) {
if (!getDoesFilePathExist(newPath)) {
createDirectorySync(newPath)
}

foldersTimestamp.add(Pair(outputFile,entry))
continue
}

val outputFile = File(newPath)
}

val isVulnerableForZipPathTraversal = !outputFile.canonicalPath.startsWith(parent)
if (isVulnerableForZipPathTraversal) {
Expand All @@ -193,7 +199,9 @@ class DecompressActivity : SimpleActivity() {
fos!!.close()
outputFile.setLastModified(entry)
}

for ((folder,header) in foldersTimestamp){
folder.setLastModified((header))
}
toast(R.string.decompression_successful)
finish()
}
Expand Down
Loading