mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 13:59:48 +01:00
simplify check if file is outside cache dir
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
f1d03e235a
commit
19a69e0abf
@ -98,12 +98,7 @@ object FileUtils {
|
||||
fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File? {
|
||||
val cachedFile = File(context.cacheDir, filename)
|
||||
|
||||
val aboveOrEqualAPI26Check =
|
||||
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
|
||||
|
||||
val isOutsideCacheDir = aboveOrEqualAPI26Check
|
||||
|
||||
if (isOutsideCacheDir) {
|
||||
if (!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())) {
|
||||
Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
||||
cachedFile.delete()
|
||||
return null
|
||||
|
Loading…
Reference in New Issue
Block a user