dm2-saves: robustness batch — silent header rewrites, silent map-table skips, recursion depth, tile-index panics, unlink-before-validate #175
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Batch of low-severity robustness items from a full-crate review. None affect the current fixtures; all are silent-misbehavior or panic hazards on unusual input.
SaveFile::to_byteszeroesn_records[11..=13](sksave.rs~466-469): the recompute usesarr.len().checked_div(size).unwrap_or(0), and sizes for types 11-13 are 0 — a save whose header carried nonzero counts for the unused types would be silently rewritten, breaking byte-exactness. Preserve the parsed counts for zero-size types.total_columnssilently skips unparseable map entries (sksave.rs~186-192,filter_map): a corrupt map table yields a wrong column sum and mis-sliced sections instead of a parse error.read_chain/write_chain(checkcode.rs): creature→possessions→creature / chest→contents→chest nesting is bounded only by input size (~60 bits per level); a multi-hundred-KB adversarial bitstream can overflow the stack (abort, not catchable). Typical fuzz input sizes won't reach it — consider a depth cap.map.tiles[...]indexing after width/height-only checks (records.rs~631is_teleporter_detail_tile, ~707 / ~1002 tile-chain decode/encode): panics if a hand-builtDungeonMapInfohastiles.len() < width*height. The walker paths (~1265) are defensive; these aren't.object_place.rs~899remove_object, ~940despawn_creature, chest/creature removals):unlink_dynamic_recordperforms irreversible chain surgery beforedecode_objectis checked; anUndecodableerror leaves the record orphaned. Validate first (or re-link on error).checkcode.rs~969/987):cloud_recordsis collected butencode_cloud_postfixreplays the decoded entries without cross-checking, so an edit that changes container-flag/missile membership silently desyncs the postfix count vs what the engine accumulates on load. AlsoCloudPostfixEntry.rec_indexis always 0 (placeholder), which is misleading to consumers.Fixed by #209 (merged into
main).