mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-25 06:55:57 +00:00
android: prevent imported archive from being written outside the export folder (#7375)
This commit is contained in:
+5
@@ -753,6 +753,11 @@ private fun saveArchiveFromURI(importedArchiveURI: URI): String? {
|
||||
if (inputStream != null && archiveName != null) {
|
||||
val archivePath = "$databaseExportDir${File.separator}$archiveName"
|
||||
val destFile = File(archivePath)
|
||||
// resolves symlinks, so it also catches a final component linking outside the folder
|
||||
if (destFile.canonicalFile.parentFile != databaseExportDir.canonicalFile) {
|
||||
Log.e(TAG, "saveArchiveFromURI path outside of export folder")
|
||||
return null
|
||||
}
|
||||
Files.copy(inputStream, destFile.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||
archivePath
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user