mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-24 23:45:19 +00:00
security: prevent storage exhaustion by saving incoming files to cache (#606)
Closes #592 - Changed FileUtils.saveIncomingFile to use context.cacheDir instead of context.filesDir. - This ensures incoming files are treated as temporary and can be cleared by the OS if space is needed. Co-authored-by: a1denvalu3 <>
This commit is contained in:
co-authored by
a1denvalu3 <>
parent
41945e6ff0
commit
e3310a34fd
@@ -197,7 +197,9 @@ object FileUtils {
|
||||
): String {
|
||||
val lowerMime = file.mimeType.lowercase()
|
||||
val isImage = lowerMime.startsWith("image/")
|
||||
val baseDir = context.filesDir
|
||||
// FIX: Use cacheDir instead of filesDir to prevent storage exhaustion attacks (Issue #592)
|
||||
// Files in cacheDir are eligible for automatic system cleanup when space is low
|
||||
val baseDir = context.cacheDir
|
||||
val subdir = if (isImage) "images/incoming" else "files/incoming"
|
||||
val dir = java.io.File(baseDir, subdir).apply { mkdirs() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user