aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/FileSystem/Content/SystemVersion.cs
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-10-25 00:13:20 +0200
committerGitHub <noreply@github.com>2021-10-24 19:13:20 -0300
commit51fa1b2cb0bb54c0eb235c9d1fa68a7e1abaf464 (patch)
tree8f47d8391bc4c2b994ccf872ca123fdd1dbb9288 /Ryujinx.HLE/FileSystem/Content/SystemVersion.cs
parentb4dc33efc2890bc0d60e99f715425d6af4a72b3d (diff)
hle: Improve safety (#2778)
* timezone: Make timezone implementation safe * hle: Do not use TrimEnd to parse ASCII strings This adds an util that handle reading an ASCII string in a safe way. Previously it was possible to read malformed data that could cause various undefined behaviours in multiple services. * hid: Remove an useless unsafe modifier on keyboard update * Address gdkchan's comment * Address gdkchan's comment
Diffstat (limited to 'Ryujinx.HLE/FileSystem/Content/SystemVersion.cs')
-rw-r--r--Ryujinx.HLE/FileSystem/Content/SystemVersion.cs9
1 files changed, 5 insertions, 4 deletions
diff --git a/Ryujinx.HLE/FileSystem/Content/SystemVersion.cs b/Ryujinx.HLE/FileSystem/Content/SystemVersion.cs
index 6e7e85fd..3f19e135 100644
--- a/Ryujinx.HLE/FileSystem/Content/SystemVersion.cs
+++ b/Ryujinx.HLE/FileSystem/Content/SystemVersion.cs
@@ -1,3 +1,4 @@
+using Ryujinx.HLE.Utilities;
using System.IO;
using System.Text;
@@ -30,10 +31,10 @@ namespace Ryujinx.HLE.FileSystem.Content
reader.ReadBytes(2); // Padding
- PlatformString = Encoding.ASCII.GetString(reader.ReadBytes(0x20)).TrimEnd('\0');
- Hex = Encoding.ASCII.GetString(reader.ReadBytes(0x40)).TrimEnd('\0');
- VersionString = Encoding.ASCII.GetString(reader.ReadBytes(0x18)).TrimEnd('\0');
- VersionTitle = Encoding.ASCII.GetString(reader.ReadBytes(0x80)).TrimEnd('\0');
+ PlatformString = StringUtils.ReadInlinedAsciiString(reader, 0x20);
+ Hex = StringUtils.ReadInlinedAsciiString(reader, 0x40);
+ VersionString = StringUtils.ReadInlinedAsciiString(reader, 0x18);
+ VersionTitle = StringUtils.ReadInlinedAsciiString(reader, 0x80);
}
}
}