From c62c9adb81c02f3adf84b0dc0af343c2d7258880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 05:24:07 +0300 Subject: [PATCH 1/2] Fix string delta compare reading past 32 bits --- Source.Engine/DtEncode.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Source.Engine/DtEncode.cs b/Source.Engine/DtEncode.cs index 35c7aa9c..bd46ffcb 100644 --- a/Source.Engine/DtEncode.cs +++ b/Source.Engine/DtEncode.cs @@ -444,6 +444,19 @@ public static void VectorXY_SkipProp(SendProp prop, bf_read p) { } #endregion #region SendPropType.String + static bool AreBitsDifferent(bf_read buf1, bf_read buf2, int bits) { + int dwords = bits >> 5; + bool diff = false; + for (int i = 0; i < dwords; i++) + diff |= buf1.ReadUBitLong(32) != buf2.ReadUBitLong(32); + + int remainingBits = bits - (dwords << 5); + if (remainingBits > 0) + diff |= buf1.ReadUBitLong(remainingBits) != buf2.ReadUBitLong(remainingBits); + + return diff; + } + public static int String_CompareDeltas(SendProp prop, bf_read p1, bf_read p2) { int len1 = (int)p1.ReadUBitLong(Constants.DT_MAX_STRING_BITS); int len2 = (int)p2.ReadUBitLong(Constants.DT_MAX_STRING_BITS); @@ -452,7 +465,7 @@ public static int String_CompareDeltas(SendProp prop, bf_read p1, bf_read p2) { if (len1 == 0) return 0; - return p1.CompareBits(p2, len1 * 8) ? 1 : 0; + return AreBitsDifferent(p1, p2, len1 * 8) ? 1 : 0; } else { p1.SeekRelative(len1 * 8); From 1f8ddd2a63c1030d767886ac0f20faa4a1a1513e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 05:32:47 +0300 Subject: [PATCH 2/2] Assert ReadUBitLong reads between 1 and 32 bits --- Source.Common/Bitbuffers/bf_read.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source.Common/Bitbuffers/bf_read.cs b/Source.Common/Bitbuffers/bf_read.cs index ab18755e..85d8d58b 100644 --- a/Source.Common/Bitbuffers/bf_read.cs +++ b/Source.Common/Bitbuffers/bf_read.cs @@ -750,6 +750,8 @@ public uint ReadUBitVar() { public uint ReadUBitLong(uint bits) => ReadUBitLong((int)bits); // macro public uint ReadUBitLong(int bits) { + Assert(bits > 0 && bits <= 32); + if (BitsLeft < bits) { curBit = dataBits; TriggerOverflow();