diff options
| author | Thomas Guillemard <me@thog.eu> | 2019-09-04 18:10:15 +0200 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2019-09-04 18:10:15 +0200 |
| commit | b9c94ada34cbd6731e6c4fe9e3ab3f66ee48f366 (patch) | |
| tree | 6970ce64d15bba48796e4f49a99fc3359c64bbcd | |
| parent | c67f0a7c4be372174278c976233a215faef71a79 (diff) | |
timezone: improve sanity checks on TimeZone Rule name (#758)
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs index 4898b2b9..4b482689 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs @@ -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) { |
