From b39bbd969c65f05552420f933bfd9bfe344879e0 Mon Sep 17 00:00:00 2001 From: yato Date: Sun, 29 Nov 2026 15:59:10 +0300 Subject: [PATCH] Harden sondib deleted-track guard --- sondib/bin/sondibd | Bin 816680 -> 816680 bytes sondib/patch_sondibd.py | 15 +++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sondib/bin/sondibd b/sondib/bin/sondibd index 9958c74d6febf1802ca057e2f8232c305ea512b3..2b5e2d5201bdf47673d96dd1473d994d6342617e 100755 GIT binary patch delta 64 zcmZ4S#&E?O!wnjajJnO5j_sO`j6lo;#LPg<0>rF9%m&2lK+FNeoIuP4#N6989eMtn F005B=61)Ha delta 64 zcmZ4S#&E?O!wnjajF!!sj_sO`j6lo;#LPg<0>rF9%m&2lK+FNeoIuP4#N6989eMtn F005Jg6374m diff --git a/sondib/patch_sondibd.py b/sondib/patch_sondibd.py index d7175ef..9521304 100644 --- a/sondib/patch_sondibd.py +++ b/sondib/patch_sondibd.py @@ -2,8 +2,8 @@ """Apply the deleted-track guard to the bundled sondibd binary. The repository ships the service as a release binary. This patch reuses an -alignment NOP sled immediately before ``st_find_sid`` and makes a matching SID -return no result when the track's deleted byte (offset 0x21d) is set. +alignment NOP sled immediately before ``st_find_sid`` and skips a matching +track when its deleted byte (offset 0x21d) is set. """ from __future__ import annotations @@ -37,14 +37,21 @@ def patch(path: Path) -> None: branch = bytes(data[match_offset:match_offset + len(OLD_BRANCH)]) if branch == bytes.fromhex("74 ca"): + # Upgrade the first revision: returning NULL immediately made callers + # that probe an old SID take a slow error path. Skipping the deleted + # record preserves the original search contract and is safe if a SID + # was ever duplicated in the in-memory table. + if data[guard_offset + 7:guard_offset + 9] == bytes.fromhex("75 39"): + data[guard_offset + 7:guard_offset + 9] = bytes.fromhex("75 2d") + path.write_bytes(data) return if branch != OLD_BRANCH or guard != OLD_GUARD: raise SystemExit(f"unexpected sondibd bytes in {path}") - # je 0x404120; then reject track+0x21d when it is non-zero. + # je 0x404120; then skip track+0x21d when it is non-zero. guard_code = bytes.fromhex( "80 b9 1d 02 00 00 00 " # cmp byte ptr [rcx+0x21d], 0 - "75 39 " # jne 0x404162 (the existing null return) + "75 2d " # jne 0x404156 (continue the search) "48 89 c8 c3" # mov rax, rcx; ret ) data[guard_offset:guard_offset + GUARD_SIZE] = guard_code.ljust(GUARD_SIZE, b"\x90")