fix potential crash with invalid OTP strings

This commit is contained in:
Philipp Crocoll
2021-07-03 13:27:10 +02:00
parent e1cd8123cf
commit 9d63578110

View File

@@ -40,14 +40,25 @@ namespace keepass2android
{
if (entry == null)
return null;
foreach (ITotpPluginAdapter adapter in _pluginAdapters)
try
{
TotpData totpData = adapter.GetTotpData(App.Kp2a.LastOpenedEntry.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key), pair => pair.Value.ReadString()), Application.Context, false);
if (totpData.IsTotpEntry)
foreach (ITotpPluginAdapter adapter in _pluginAdapters)
{
return adapter;
TotpData totpData = adapter.GetTotpData(
App.Kp2a.LastOpenedEntry.OutputStrings.ToDictionary(pair => StrUtil.SafeXmlString(pair.Key),
pair => pair.Value.ReadString()), Application.Context, false);
if (totpData.IsTotpEntry)
{
return adapter;
}
}
}
catch (Exception e)
{
Kp2aLog.LogUnexpectedError(e);
}
return null;
}