fix(mysql): bounds-check ItemList index + clamp KnownSpells in dormant MySQL actor load (static-only)#566
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Brings the MySQL actor loader (
My_LoadActorInstance,src/Modules/MySQL.bb) to parity with the hardened flat-file loader (ReadActorInstance,Actors.bb):If ID < 0 Or ID > 65534 ... ElseIf ItemList(ID) = Null ... Else ...so the range test sits in its own branch ahead of anyItemList(ID)deref. Required because BlitzForgeOris non-short-circuit — an inline... Or ItemList(ID)=Nullwould still wild-indexItemListat an arbitrary DB-supplied offset. (ItemListisDim(65534).)KnownSpells/SpellLevelsclamp — out-of-range spell ids from a DB row are zeroed, identical to the flat-file analog atActors.bb:535-538(SpellsListisDim(65534)).Both soft-fail (WriteLog + skip/clamp), purely additive; valid data is unchanged.
Be explicit:
MySQL.bbis not built by anything.src/Server.bbhas//Include "Modules\MySQL.bb"commented out and no other target includes it, so neither localcompile.batnor CI parses this file. A temporary-include experiment further showed the module cannot compile in this tree at all — it fails atmysql.bb:60(Type BBThreadcollides with theSQLDLL.dlluserlib insrc/userlibs/BBThread.decls), which is the real reason it's disabled.Consequences:
BBThreadcollision fixed first).Actors.bbanalog, bounds matched to the actualDims, syntax matched to 7 existing in-fileElseIfblocks). 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