catch potential crash when otp data is invalid

closes https://github.com/PhilippC/keepass2android/issues/1602
This commit is contained in:
Philipp Crocoll
2024-01-05 09:27:34 +01:00
parent 4fea731c87
commit c354612369

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using Android.Content;
using keepass2android;
using KeePassLib.Collections;
namespace PluginTOTP
@@ -51,13 +52,22 @@ namespace PluginTOTP
{
return res;
}
res.TotpSeed = parameters[KeyParameter];
try
{
res.TotpSeed = parameters[KeyParameter];
res.Duration = GetIntOrDefault(parameters, StepParameter, 30).ToString();
res.Length = GetIntOrDefault(parameters, SizeParameter, 6).ToString();
res.IsTotpEntry = true;
}
catch (Exception e)
{
Kp2aLog.Log("Cannot parse seed");
}
res.Duration = GetIntOrDefault(parameters, StepParameter, 30).ToString();
res.Length = GetIntOrDefault(parameters, SizeParameter, 6).ToString();
res.IsTotpEntry = true;
return res;
}