Skip to content

fix(mysql): bounds-check ItemList index + clamp KnownSpells in dormant MySQL actor load (static-only)#566

Merged
CoreyRDean merged 1 commit into
developfrom
harden/load-path-bounds-tests
Jun 10, 2026
Merged

fix(mysql): bounds-check ItemList index + clamp KnownSpells in dormant MySQL actor load (static-only)#566
CoreyRDean merged 1 commit into
developfrom
harden/load-path-bounds-tests

Conversation

@CoreyRDean

Copy link
Copy Markdown
Collaborator

What

Brings the MySQL actor loader (My_LoadActorInstance, src/Modules/MySQL.bb) to parity with the hardened flat-file loader (ReadActorInstance, Actors.bb):

  1. Item-ID range guard — restructured to If ID < 0 Or ID > 65534 ... ElseIf ItemList(ID) = Null ... Else ... so the range test sits in its own branch ahead of any ItemList(ID) deref. Required because BlitzForge Or is non-short-circuit — an inline ... Or ItemList(ID)=Null would still wild-index ItemList at an arbitrary DB-supplied offset. (ItemList is Dim(65534).)
  2. KnownSpells / SpellLevels clamp — out-of-range spell ids from a DB row are zeroed, identical to the flat-file analog at Actors.bb:535-538 (SpellsList is Dim(65534)).

Both soft-fail (WriteLog + skip/clamp), purely additive; valid data is unchanged.

⚠️ Verification status: STATIC-ONLY (dormant, non-compiling module)

Be explicit: MySQL.bb is not built by anything. src/Server.bb has //Include "Modules\MySQL.bb" commented out and no other target includes it, so neither local compile.bat nor CI parses this file. A temporary-include experiment further showed the module cannot compile in this tree at all — it fails at mysql.bb:60 (Type BBThread collides with the SQLDLL.dll userlib in src/userlibs/BBThread.decls), which is the real reason it's disabled.

Consequences:

  • This change has zero impact on any shipping binary — it hardens dormant code for a hypothetical future MySQL revival (which would also need the BBThread collision fixed first).
  • It is verified by independent static review only (byte-for-byte parity with the compiled Actors.bb analog, bounds matched to the actual Dims, syntax matched to 7 existing in-file ElseIf blocks). No compiler has parsed the edited function.

Merging is safe precisely because the code is inert; it is intentionally not claimed as compiler-verified.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

…actor load

Bring My_LoadActorInstance to parity with the hardened flat-file loader
(ReadActorInstance / ReadItemInstance). The DB-supplied item id and
known-spell id are raw ReadSQLField values; a corrupt/tampered row could
OOB-index ItemList (Dim 65534) or drive an OOB SpellsList read on the
shared server. Range-guard the item id in its own branch (BlitzForge Or
is non-short-circuit) and clamp KnownSpells to 0..65534, zeroing the
paired SpellLevels, mirroring the flat-file path. Purely additive; valid
data is unaffected.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CoreyRDean CoreyRDean requested a review from a team as a code owner June 10, 2026 19:58
@CoreyRDean CoreyRDean merged commit cea4700 into develop Jun 10, 2026
1 check passed
@CoreyRDean CoreyRDean deleted the harden/load-path-bounds-tests branch June 10, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant