Commit 0eb16b8
committed
fix(zig): repair broken CWE-704 fix using std.mem.sliceTo (was spanZ)
The previous CWE-704 fix in e72eae0 replaced @ptrCast with
`std.mem.spanZ`, which was removed from Zig stdlib in 0.14 — under the
0.15.1 CI pin the Zig FFI tests will not even compile. The other site
(`local_coord_ffi.zig:3291`) also used invalid syntax:
if (json_args != null) |ja| std.mem.spanZ(ja) else "{}"
[*c] pointers are null-checked with `== null`; the `|payload|` capture
form is for optionals, not C-compat pointers.
Switch to `std.mem.sliceTo(ptr, 0)`, which:
* exists in Zig 0.15.x;
* accepts `[*c]const u8` directly with no `@ptrCast`;
* scans up to the first NUL and returns a `[]const u8`;
* fully addresses the CWE-704 finding (no unchecked pointer
type conversion remains in the modified call sites).
Files:
* cartridges/local-coord-mcp/ffi/cartridge_shim.zig — toolIs()
* cartridges/local-coord-mcp/ffi/local_coord_ffi.zig — boj_cartridge_invoke()
tool + args extraction.
This unblocks the failing "Zig FFI Tests" check on PR #146 and lets
the dependent "E2E — Full REST + MCP Bridge" and "Emit manifest +
verify FFI" jobs run against a compilable library.1 parent e72eae0 commit 0eb16b8
2 files changed
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | | - | |
| 68 | + | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3287 | 3287 | | |
3288 | 3288 | | |
3289 | 3289 | | |
3290 | | - | |
3291 | | - | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
| 3293 | + | |
| 3294 | + | |
| 3295 | + | |
| 3296 | + | |
3292 | 3297 | | |
3293 | 3298 | | |
3294 | 3299 | | |
| |||
0 commit comments