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