Build `git -C " " 2> ` with a shell-validated repo path. * repo_path is the only untrusted component; args is a trusted literal or a * hex-validated commit string (never arbitrary data). Returns false on * shell-arg validation failure or truncation. */
| 378 | * hex-validated commit string (never arbitrary data). Returns false on |
| 379 | * shell-arg validation failure or truncation. */ |
| 380 | static bool build_git_cmd(char *buf, size_t bufsz, const char *repo_path, const char *args) { |
| 381 | if (!cbm_artifact_repo_path_is_shell_safe(repo_path)) { |
| 382 | return false; |
| 383 | } |
| 384 | int n = snprintf(buf, bufsz, "git -C \"%s\" %s 2>" ARTIFACT_NULL_DEV, repo_path, args); |
| 385 | return n >= 0 && (size_t)n < bufsz; |
| 386 | } |
| 387 | |
| 388 | /* Run a git command; return true iff it exits 0. Output is drained (not kept) |
| 389 | * so `diff --quiet` semantics work and large outputs don't SIGPIPE. */ |
no test coverage detected