timezone: improve sanity checks on TimeZone Rule name (#758)
This commit is contained in:
parent
c67f0a7c4b
commit
b9c94ada34
1 changed files with 33 additions and 1 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Reference in a new issue