timezone: improve sanity checks on TimeZone Rule name (#758)

This commit is contained in:
Thomas Guillemard 2019-09-04 18:10:15 +02:00 committed by Ac_K
parent c67f0a7c4b
commit b9c94ada34

View file

@ -197,6 +197,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
num = 0;
if (namePosition >= name.Length)
{
return false;
}
char c = name[namePosition];
if (!char.IsDigit(c))
@ -212,7 +217,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return false;
}
c = name[++namePosition];
if (++namePosition >= name.Length)
{
return false;
}
c = name[namePosition];
}
while (char.IsDigit(c));
@ -237,6 +247,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
seconds = num * SecondsPerHour;
if (namePosition >= name.Length)
{
return false;
}
if (name[namePosition] == ':')
{
namePosition++;
@ -247,6 +263,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
seconds += num * SecondsPerMinute;
if (namePosition >= name.Length)
{
return false;
}
if (name[namePosition] == ':')
{
namePosition++;
@ -266,6 +288,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
bool isNegative = false;
if (namePosition >= name.Length)
{
return false;
}
if (name[namePosition] == '-')
{
isNegative = true;
@ -276,6 +303,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
namePosition++;
}
if (namePosition >= name.Length)
{
return false;
}
bool isValid = GetSeconds(name, ref namePosition, out offset);
if (!isValid)
{