From 7a7c68fc910dc1370f36df49f18c0b4ae9aaacbc Mon Sep 17 00:00:00 2001 From: jvyden Date: Thu, 14 Oct 2021 19:24:19 -0400 Subject: [PATCH] Trim null byte from LoginData username --- ProjectLighthouse/Controllers/LoginController.cs | 1 - ProjectLighthouse/Types/LoginData.cs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index c6f9b1e6..5b137aa4 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -12,7 +12,6 @@ namespace ProjectLighthouse.Controllers { [Route("LITTLEBIGPLANETPS3_XML/login")] [Produces("text/xml")] public class LoginController : ControllerBase { - [HttpGet] [HttpPost] public async Task Login() { if(!this.Request.Query.TryGetValue("titleID", out StringValues _)) diff --git a/ProjectLighthouse/Types/LoginData.cs b/ProjectLighthouse/Types/LoginData.cs index eca52562..2c215933 100644 --- a/ProjectLighthouse/Types/LoginData.cs +++ b/ProjectLighthouse/Types/LoginData.cs @@ -21,9 +21,9 @@ namespace ProjectLighthouse.Types { public static LoginData CreateFromString(string str) { do { - str = str.Replace("\b", ""); + str = str.Replace("\b", string.Empty); // Trim backspace characters } while(str.Contains('\b')); - + using MemoryStream ms = new(Encoding.ASCII.GetBytes(str)); using BinaryReader reader = new(ms); @@ -34,7 +34,7 @@ namespace ProjectLighthouse.Types { // byte[] endBytes = reader.ReadBytes((int)(ms.Length - reader.BaseStream.Position)); // string end = Encoding.ASCII.GetString(endBytes); - loginData.Username = BinaryHelper.ReadString(reader); + loginData.Username = BinaryHelper.ReadString(reader).Replace("\0", string.Empty); return loginData; }