diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 23:27:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 23:32:29 -0300 |
| commit | 5b4f790453c636ab10a0be2686008af7a67e0afe (patch) | |
| tree | 59063fba659c0f69e8b79576532e955f20d6b1f3 /core/Db.zig | |
| parent | 263b7d2e24f5bdad6a6a62b4a13bc74b8be68cb3 (diff) | |
| download | pardes-5b4f790453c636ab10a0be2686008af7a67e0afe.tar.gz pardes-5b4f790453c636ab10a0be2686008af7a67e0afe.zip | |
walk: every count a byte dump or an image holds is held to the bytes it came in, and the fuzz reads the byte dump a join streams as a join does: core/fuzz.zig's dump fuzz had read two IMAGES (`dump.dumpBytes` is an image too), so the byte loader a client's join runs (`walk.Load`, before the session's digest is checked) was never fuzzed; now its two wholes are `dump.byteDump` read as a join reads it (`Road.join`: loaded, digested, let go) and the image read as a Restore or an Upgrade reads it (`Road.restore`: loaded, drawn), 4096 seeds and 1024 (seconds each). EACH SITE BELOW WAS A RUN OF IT FIRST, then the fix: the join road's seed 96, `Loader.readInt` on a same-build dump `@intCast` a byte-wide word into a narrower int (`integer does not fit`): `std.math.cast`, BadDump; the table's counts sized allocations of 240 GB (an enum's names, a u32 read): `Loader.entries`, each count held to the bytes left by the least an entry takes (a type 1, a name and value 18, a field 6); seed 456, `skip` over a damaged table where a struct is its own field recursed to a stack overflow (a segfault): `max_depth` 256 (a session's types nest about twenty); seed 1835, a same-build enum read with `@fromBackingInt` (`invalid enum value`): `std.enums.fromInt` (`enumFrom`'s rule), BadDump; the restore road's seed 672, an image's list count sized a 10 TB allocation (`Get.slice`): held to the slots the image's bytes hold; and its byte values read with no bound (`readBytesObjectAlloc(.., null)`: 12 EB asked): `walk.most` (the database's length) at each of `Get`'s reads and `Db.Read.open`'s session. Then the counts the fuzz did not reach, by the same rule and a test that fails without it (`integer overflow` in `initEmpty`'s and `skip`'s `bits + 63`): a bitset's count (`Loader.bitCount`, read and passed over; `Get`'s), a slice's count and an array's or a skip's loop held to the bytes LEFT (were the whole dump's, or none: a loop of 2^64 skips); test walk.zig "a bitset's count read back is held to the bytes left, read or passed over, in a dump and an image: never a size that overflows". OPEN, not done here: the image road past seed 1024 reaches xitdb's own reader (seed 1780: `switch on corrupt value` in xitdb `HashMap.init`, a slot's tag byte past its kinds, from `Db.Read.blobs`): a dependency's, for build/patches.zig and a report; a byte dump that loads but means nothing (a live view that is none: a Restore of an old byte-dump file draws it and panics in `Core.view`); references read back as another type (no-panic-1's `typeWord` sites, not reached in 4096 seeds)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Db.zig')
| -rw-r--r-- | core/Db.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/Db.zig b/core/Db.zig index 254eb4a7..eb8ee20c 100644 --- a/core/Db.zig +++ b/core/Db.zig @@ -487,7 +487,7 @@ pub const Read = struct { r.names = if (entry.getCursor(key("names")) catch null) |c| @constCast(c.readBytesAlloc(gpa, 4096) catch &.{}) else &.{}; errdefer if (r.names.len > 0) gpa.free(r.names); const at = (entry.getCursor(key("session")) catch return error.NotADump) orelse return error.NotADump; - const session: []u8 = @constCast(at.readBytesAlloc(gpa, null) catch |err| return if (err == error.OutOfMemory) error.OutOfMemory else error.NotADump); + const session: []u8 = @constCast(at.readBytesAlloc(gpa, pardes.walk.most(at)) catch |err| return if (err == error.OutOfMemory) error.OutOfMemory else error.NotADump); var owned: std.ArrayList(u8) = .fromOwnedSlice(session); r.session_buf = .fromArrayList(gpa, &owned); errdefer r.session_buf.deinit(); |
