Skip to content

Commit

Permalink
Merge branch 'crash-in-split-tunneling-due-to-too-large-app-icon-droi…
Browse files Browse the repository at this point in the history
…d-846'
  • Loading branch information
Rawa committed Apr 5, 2024
2 parents 5d94293 + 380080c commit e859f00
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
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
}

0 comments on commit e859f00

Please sign in to comment.