mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 22:04:24 +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? {
|
fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File? {
|
||||||
val cachedFile = File(context.cacheDir, filename)
|
val cachedFile = File(context.cacheDir, filename)
|
||||||
|
|
||||||
val aboveOrEqualAPI26Check =
|
if (!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())) {
|
||||||
!cachedFile.toPath().normalize().startsWith(context.cacheDir.toPath())
|
|
||||||
|
|
||||||
val isOutsideCacheDir = aboveOrEqualAPI26Check
|
|
||||||
|
|
||||||
if (isOutsideCacheDir) {
|
|
||||||
Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
||||||
cachedFile.delete()
|
cachedFile.delete()
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user