aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-03 15:37:31 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-03 15:37:31 +0530
commitac79c5b1f7fb2703f9304d1acd6a6766ca123b72 (patch)
treeef8bfa21671e605ba37faf26da7300305f7872f9 /WireGuard
parentUpdate readme (diff)
downloadwireguard-apple-ac79c5b1f7fb2703f9304d1acd6a6766ca123b72.tar.xz
wireguard-apple-ac79c5b1f7fb2703f9304d1acd6a6766ca123b72.zip
Zip archive: Handle files within folders inside the zip
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/ZipArchive/ZipArchive.swift8
1 files changed, 4 insertions, 4 deletions
diff --git a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
index 7f654adc..d9078031 100644
--- a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
+++ b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
@@ -61,10 +61,10 @@ class ZipArchive {
throw ZipArchiveError.badArchive
}
- let fileName = String(cString: fileNameBuffer)
- let fileExtension = URL(string: fileName)?.pathExtension ?? ""
+ if let fileURL = URL(string: String(cString: fileNameBuffer)),
+ !fileURL.hasDirectoryPath,
+ requiredFileExtensions.contains(fileURL.pathExtension) {
- if (requiredFileExtensions.contains(fileExtension)) {
var unzippedData = Data()
var bytesRead: Int32 = 0
repeat {
@@ -77,7 +77,7 @@ class ZipArchive {
unzippedData.append(dataRead)
}
} while (bytesRead > 0)
- results.append((fileName: fileName, contents: unzippedData))
+ results.append((fileName: fileURL.lastPathComponent, contents: unzippedData))
}
guard (unzCloseCurrentFile(zipFile) == UNZ_OK) else {