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

Function cbm_build_win_cmdline

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

208 * containing a quote (e.g. the index JSON {"repo_path":"…"}), corrupting the
209 * spawned child's argv. */
210bool cbm_build_win_cmdline(char *buf, size_t cap, const char *const *argv) {
211 if (!buf || cap == 0 || !argv) {
212 return false;
213 }
214 size_t pos = 0;
215 bool ovf = false;
216 for (int i = 0; argv[i]; i++) {
217 pos = cbm_cmdline_append_arg(buf, cap, pos, argv[i], i == 0, &ovf);
218 if (ovf) {
219 buf[0] = '\0'; /* overflow: leave buf a valid (empty) string, never unterminated */
220 return false;
221 }
222 }
223 buf[pos] = '\0';
224 return true;
225}
226
227#ifdef _WIN32
228

Callers 4

cbm_run_winFunction · 0.85
index_thread_fnFunction · 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