Commit a4bd4e7
committed
fix: 4 more issues from deep audit (argon2id bounds, arithmetic overflow, NaN bypass, unreachable FFI field)
Continuing the audit sweep into cap:ffi, the remaining capability
modules, copy-paste-divergence patterns, and numeric edge cases.
- crypto.zig argon2id: t/m/p validated only lower bounds (unlike
bcryptHash's cost, bounded both ways) before @intCast-ing them into
argon2.Params' u32/u32/u24 fields -- an out-of-range value panicked
that cast immediately, a crash trivially reachable from Gengo source.
- vm.zig .mod opcode: missing the minInt(i64)/-1 overflow guard its
siblings .int_div/.rem already have (a copy-paste divergence found by
audit) -- @mod traps/UB's on the same 2^63 overflow. Also fixed
.int_div's OTHER path (named/decimal-typed operands, reached via
numericBinaryOp) which silently returned minInt(i64) instead of
erroring like its plain-int sibling already does.
- cap_net.zig extractHandle/extractUsize/extractI64: NaN compares
false against every ordinary comparison, so `n < 0 or n > MAX`
guards silently passed NaN through to @intFromFloat -- the same
hazard floatToIntSafe (vm.zig) exists to close, reimplemented here
without that check. Added isFinite guards to all three.
- module_compile.zig: ffi.buf_from_ptr was fully implemented
(cap_ffi.zig) but permanently unreachable -- missing from the
compiler's cap:ffi field allowlist, so any script referencing it
failed to compile at all. Verified fixed via the CLI.
Verified clean under standard, -Dpreset=stress, and -Dgc_stress=true.1 parent c92071c commit a4bd4e7
4 files changed
Lines changed: 44 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
962 | 962 | | |
963 | 963 | | |
964 | 964 | | |
965 | | - | |
966 | | - | |
967 | | - | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
968 | 973 | | |
969 | 974 | | |
970 | | - | |
| 975 | + | |
971 | 976 | | |
972 | 977 | | |
973 | 978 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | 39 | | |
33 | 40 | | |
| |||
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
44 | | - | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
| |||
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | | - | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
457 | 466 | | |
458 | 467 | | |
459 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3298 | 3298 | | |
3299 | 3299 | | |
3300 | 3300 | | |
3301 | | - | |
| 3301 | + | |
| 3302 | + | |
| 3303 | + | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
3302 | 3311 | | |
3303 | 3312 | | |
3304 | 3313 | | |
| |||
3344 | 3353 | | |
3345 | 3354 | | |
3346 | 3355 | | |
3347 | | - | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
3348 | 3361 | | |
3349 | 3362 | | |
3350 | 3363 | | |
| |||
0 commit comments