From 172a857604ce0dda7c0f26455cdd04eb062c579a Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Mon, 12 Jul 2021 12:31:39 -0400 Subject: [PATCH] handle intent exceptions to prevent denial of service (#1458) --- src/Android/MainActivity.cs | 51 +++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs index 876214114..92fa32f41 100644 --- a/src/Android/MainActivity.cs +++ b/src/Android/MainActivity.cs @@ -155,33 +155,40 @@ namespace Bit.Droid protected override void OnNewIntent(Intent intent) { base.OnNewIntent(intent); - if (intent.GetBooleanExtra("generatorTile", false)) + try { - _messagingService.Send("popAllAndGoToTabGenerator"); - if (_appOptions != null) + if (intent.GetBooleanExtra("generatorTile", false)) { - _appOptions.GeneratorTile = true; + _messagingService.Send("popAllAndGoToTabGenerator"); + if (_appOptions != null) + { + _appOptions.GeneratorTile = true; + } + } + else if (intent.GetBooleanExtra("myVaultTile", false)) + { + _messagingService.Send("popAllAndGoToTabMyVault"); + if (_appOptions != null) + { + _appOptions.MyVaultTile = true; + } + } + else if (intent.Action == Intent.ActionSend && intent.Type != null) + { + if (_appOptions != null) + { + _appOptions.CreateSend = GetCreateSendRequest(intent); + } + _messagingService.Send("popAllAndGoToTabSend"); + } + else + { + ParseYubiKey(intent.DataString); } } - else if (intent.GetBooleanExtra("myVaultTile", false)) + catch (Exception e) { - _messagingService.Send("popAllAndGoToTabMyVault"); - if (_appOptions != null) - { - _appOptions.MyVaultTile = true; - } - } - else if (intent.Action == Intent.ActionSend && intent.Type != null) - { - if (_appOptions != null) - { - _appOptions.CreateSend = GetCreateSendRequest(intent); - } - _messagingService.Send("popAllAndGoToTabSend"); - } - else - { - ParseYubiKey(intent.DataString); + System.Diagnostics.Debug.WriteLine(">>> {0}: {1}", e.GetType(), e.StackTrace); } }