Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

lint: clang-format compliance, fork allowlist entry, reduce bin scope

Martin Vogel6e59736711b3
diff --git a/internal/cbm/cbm.c b/internal/cbm/cbm.c
index 67b6b28e4..576f9cddd 100644
--- a/internal/cbm/cbm.c
+++ b/internal/cbm/cbm.c
@@ -14,7 +14,7 @@
#include "lsp/rust_lsp.h"
#include "preprocessor.h"
#include "foundation/compat.h"
-#include "foundation/compat_fs.h" // cbm_fopen — crash-supervisor per-file marker write
+#include "foundation/compat_fs.h" // cbm_fopen — crash-supervisor per-file marker write
#include "foundation/hash_table.h" // CBMHashTable — crash-supervisor quarantine set
#include "tree_sitter/api.h" // TSParser, TSNode, TSTree, TSInput, TSLanguage, TSPoint, TSParseOptions, TSParseState
#include "foundation/constants.h"
diff --git a/scripts/security-allowlist.txt b/scripts/security-allowlist.txt
index 1b07f0e5b..259a40e8e 100644
--- a/scripts/security-allowlist.txt
+++ b/scripts/security-allowlist.txt
@@ -8,6 +8,7 @@
src/foundation/compat_fs.c:popen:cbm_popen wrapper definition (POSIX)
src/foundation/compat_fs.c:cbm_popen:cbm_popen function definition
src/foundation/compat_fs.c:fork:cbm_exec_no_shell — fork+execvp for shell-free subprocess execution
+src/foundation/subprocess.c:fork:cbm_run_posix — fork+execv for the crash/hang-isolating index worker (supervisor primitive; child execs immediately, no code runs in the forked image)
src/foundation/compat_fs.c:execvp:cbm_exec_no_shell — direct exec without shell interpretation
# ── CLI: update command (user-initiated, interactive) ──────────────────────
diff --git a/src/foundation/subprocess.c b/src/foundation/subprocess.c
index 0f3b0ad7c..3167a1b20 100644
--- a/src/foundation/subprocess.c
+++ b/src/foundation/subprocess.c
@@ -214,8 +214,6 @@ static int cbm_run_win(const cbm_proc_opts_t *opts, cbm_proc_result_t *out) {
#else /* POSIX */
static int cbm_run_posix(const cbm_proc_opts_t *opts, cbm_proc_result_t *out) {
- const char *bin = opts->bin;
-
pid_t pid = fork();
if (pid < 0) {
out->outcome = CBM_PROC_SPAWN_FAILED;
@@ -230,6 +228,7 @@ static int cbm_run_posix(const cbm_proc_opts_t *opts, cbm_proc_result_t *out) {
* threads plus mimalloc/sqlite/libgit2 global state), and a fork() copies
* only the calling thread — a malloc between fork and exec could deadlock on
* a lock another thread held at fork time. open/dup2/execv touch no heap. */
+ const char *bin = opts->bin;
const char *const default_argv[] = {bin, NULL};
const char *const *argv = opts->argv ? opts->argv : default_argv;
const char *target = opts->log_file ? opts->log_file : "/dev/null";
diff --git a/src/mcp/index_supervisor.c b/src/mcp/index_supervisor.c
index 56c218f0d..74c393186 100644
--- a/src/mcp/index_supervisor.c
+++ b/src/mcp/index_supervisor.c
@@ -6,8 +6,8 @@
#include "foundation/compat.h" /* cbm_setenv, cbm_unsetenv */
#include "foundation/compat_fs.h" /* cbm_mkdir_p, cbm_fopen */
#include "foundation/log.h"
-#include "foundation/platform.h" /* cbm_resolve_cache_dir */
-#include "ui/http_server.h" /* cbm_http_server_resolve_binary_path */
+#include "foundation/platform.h" /* cbm_resolve_cache_dir */
+#include "ui/http_server.h" /* cbm_http_server_resolve_binary_path */
#include <stdio.h>
#include <stdlib.h>
@@ -202,7 +202,8 @@ int cbm_index_spawn_worker(const char *args_json, bool single_thread, const char
char sig[16];
snprintf(sig, sizeof(sig), "%d", r.term_signal);
- cbm_log_info("index.supervisor.reap", "outcome", cbm_proc_outcome_str(r.outcome), "signal", sig);
+ cbm_log_info("index.supervisor.reap", "outcome", cbm_proc_outcome_str(r.outcome), "signal",
+ sig);
return 0;
}