MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_build_win_cmdline

Function cbm_build_win_cmdline

src/foundation/subprocess.c:285–300  ·  view source on GitHub ↗

Build a full Windows CreateProcess command line from a NULL-terminated argv, * applying the MS C runtime quoting rules so the child re-parses byte-identical * argv. Returns true on success, false if the result would overflow `buf`. * * Defined unconditionally (pure string logic, no Windows headers) so the quoting * contract is unit-tested on Linux/macOS CI too — even though the real spawn pat

Source from the content-addressed store, hash-verified

283 * containing a quote (e.g. the index JSON {"repo_path":"…"}), corrupting the
284 * spawned child's argv. */
285bool cbm_build_win_cmdline(char *buf, size_t cap, const char *const *argv) {
286 if (!buf || cap == 0 || !argv) {
287 return false;
288 }
289 size_t pos = 0;
290 bool ovf = false;
291 for (int i = 0; argv[i]; i++) {
292 pos = cbm_cmdline_append_arg(buf, cap, pos, argv[i], i == 0, &ovf);
293 if (ovf) {
294 buf[0] = '\0'; /* overflow: leave buf a valid (empty) string, never unterminated */
295 return false;
296 }
297 }
298 buf[pos] = '\0';
299 return true;
300}
301
302static bool cbm_ascii_case_equal(const char *left, const char *right) {
303 if (!left || !right) {

Callers 4

cbm_subprocess_spawn_winFunction · 0.85
cmdline_roundtripsFunction · 0.85
test_subprocess.cFile · 0.85

Calls 1

cbm_cmdline_append_argFunction · 0.85

Tested by 1

cmdline_roundtripsFunction · 0.68