Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid rendering bitmaps above 100MB #6071

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ Line wrap the file at 100 chars. Th
- Fix pointless API access method rotations for concurrent requests.
- Fix daemon rotating logs on startup even if another daemon is already running.

#### Android
- Fix crash in Split Tunneling screen caused by apps provding icons bigger than 100MB.

### Security
#### Android
- Change from singleTask to singleInstance to fix Task Affinity Vulnerability in Android 8.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.component.SpacedColumn
import net.mullvad.mullvadvpn.compose.util.isBelowMaxBitmapSize
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.lib.theme.Dimens
import net.mullvad.mullvadvpn.lib.theme.color.Alpha40
Expand Down Expand Up @@ -75,7 +76,9 @@ fun SplitTunnelingCell(
LaunchedEffect(packageName) {
launch(Dispatchers.IO) {
val bitmap = onResolveIcon(packageName ?: "")
icon = bitmap?.asImageBitmap()
if (bitmap != null && bitmap.isBelowMaxBitmapSize()) {
icon = bitmap.asImageBitmap()
}
}
}
BaseCell(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.mullvad.mullvadvpn.compose.util

import android.graphics.Bitmap

private const val MAX_BITMAP_SIZE_BYTES = 100 * 1024 * 1024

fun Bitmap.isBelowMaxBitmapSize(): Boolean = byteCount < MAX_BITMAP_SIZE_BYTES
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ fun PackageManager.getApplicationIconBitmapOrNull(packageName: String): Bitmap?
} catch (e: IllegalArgumentException) {
// IllegalArgumentException is thrown if the application has an invalid icon
null
} catch (e: OutOfMemoryError) {
// OutOfMemoryError is thrown if the icon is too large
null
}
Loading