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

Function cbm_build_win_cmdline

src/foundation/subprocess.c:286–301  ·  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

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