From 5fdee9f31327b74580af95ca450766f5c6814719 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Jul 2026 16:20:37 +0000 Subject: [PATCH] fix(bug-filing-mcp): drop unnecessary @ptrCast from the adapter dispatch call (CWE-704) Follow-up to #89 (which fixed the FFI shim's internal ptrCasts) and #90 (which shipped the adapter with the old pattern, mirrored from k9iser-mcp before that cartridge's own equivalent was cleaned up). The three @ptrCast calls at the dispatch call site were unnecessary: Zig's [*c] pointer parameters accept array/slice/scalar pointers via implicit C-pointer coercion, verified by a standalone build-obj test before touching the real file. Re-verified with the real toolchain after the edit: zig build test green; rebuilt the binary and re-ran the live smoke test (REST dispatch + 404 on unknown route) to confirm no behavioral change. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_017LDhR8gtnittEWSafunnrq --- .../bug-filing-mcp/adapter/bug_filing_mcp_adapter.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cartridges/domains/development/bug-filing-mcp/adapter/bug_filing_mcp_adapter.zig b/cartridges/domains/development/bug-filing-mcp/adapter/bug_filing_mcp_adapter.zig index 790fffe..b824830 100644 --- a/cartridges/domains/development/bug-filing-mcp/adapter/bug_filing_mcp_adapter.zig +++ b/cartridges/domains/development/bug-filing-mcp/adapter/bug_filing_mcp_adapter.zig @@ -103,7 +103,10 @@ fn dispatch(tool: []const u8, args_json: []const u8, out: []u8) Dispatch { abuf[a.len] = 0; var len: usize = out.len; - const rc = ffi.boj_cartridge_invoke(@ptrCast(&tnbuf), @ptrCast(&abuf), @ptrCast(out.ptr), &len); + // No @ptrCast needed (CWE-704 fix, matching #89's cartridge_shim.zig + // pattern): [*c] parameters accept array/slice/scalar pointers via + // Zig's own implicit C-pointer coercion. + const rc = ffi.boj_cartridge_invoke(&tnbuf, &abuf, out.ptr, &len); return switch (rc) { 0 => .{ .status = 200, .body = out[0..len] }, -1 => .{ .status = 404, .body = "{\"error\":\"unknown-tool\"}" },