From ec4b47c15d28b42f376b01aeef25e65e67433206 Mon Sep 17 00:00:00 2001 From: Reece Wilson Date: Thu, 21 Jul 2022 07:30:25 +0100 Subject: [PATCH] [*] Increase IPCHandle checksum bitlength --- Source/IO/IPC/IPCHandle.cpp | 54 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/Source/IO/IPC/IPCHandle.cpp b/Source/IO/IPC/IPCHandle.cpp index 75158078..d4940548 100644 --- a/Source/IO/IPC/IPCHandle.cpp +++ b/Source/IO/IPC/IPCHandle.cpp @@ -105,45 +105,50 @@ namespace Aurora::IO::IPC } AuUInt32 magic {0x811c9dc5}; - for (int i = 0; i < in.size() - 1; i++) + for (int i = 0; i < in.size() - 2; i++) { magic ^= (in[i] * 0x01000193); } - if (AuUInt8(AuUInt8(in[in.size() - 1] - 'A') & 15) != AuUInt8(magic & 15)) + if (AuUInt8(AuUInt8(in[in.size() - 2] - 'A') & 15) != AuUInt8(magic & 15)) { return false; } -#define READ_NEXT_TOKEN \ - { \ - nextToken.clear(); \ - \ - if (((in.size() - stringOffset) < 2)) \ - { \ - return false; \ - } \ - \ - char cur; \ - while (((stringOffset) < in.size()) && \ - ((cur = in[stringOffset]) != ':')) \ - { \ - nextToken.push_back(cur); \ - stringOffset++; \ - } \ - stringOffset++; \ + if (AuUInt8(AuUInt8(in[in.size() - 1] - 'A') & 15) != AuUInt8((magic >> 4) & 15)) + { + return false; + } + +#define READ_NEXT_TOKEN \ + { \ + nextToken.clear(); \ + \ + if (((in.size() - stringOffset) < 2)) \ + { \ + return false; \ + } \ + \ + char cur; \ + while (((stringOffset) < in.size()) && \ + ((cur = in[stringOffset]) != ':')) \ + { \ + nextToken.push_back(cur); \ + stringOffset++; \ + } \ + stringOffset++; \ } #define READ_NEXT_INT \ { \ char cur; \ - auto startOffset = stringOffset; \ - while (((stringOffset) < in.size()) && \ - ((cur = in[stringOffset]) != ':')) \ + auto startOffset = stringOffset; \ + while (((stringOffset) < in.size()) && \ + ((cur = in[stringOffset]) != ':')) \ { \ stringOffset++; \ } \ - const char *endPtr = &in[stringOffset]; \ + const char *endPtr = &in[stringOffset]; \ const char *startPtr = &in[startOffset]; \ stringOffset++; \ auto nextIntOpt = AuParse::ParseUInt(startPtr, endPtr); \ @@ -285,13 +290,14 @@ namespace Aurora::IO::IPC } - AuUInt32 magic {0x811c9dc5}; + AuUInt32 magic {0x811c9dc5}; for (int i = 0; i < ret.size(); i++) { magic ^= (ret[i] * 0x01000193); } ret.push_back(((magic & 15) + 'A')); + ret.push_back((((magic >> 4) & 15) + 'A')); return ret; }