[PATCH 09/15] remote: handle NULL value for remotes.<group>
- From
Thomas Bachem via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Nov 7, 2026, 08:42 UTC
- Message-ID
- <0faf4e884f09de348439179a86fd2a6de5d5124a.1794040968.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2297.git.1794040967.gitgitgadget@gmail.com>
From: Thomas Bachem <mail@thomasbachem.com>
A remotes.<group> without a value makes "git fetch <group>" and "git push <group>" segfault: get_remote_group() dereferences the NULL value as it splits the list of remotes.
Reject a missing value with config_error_nonbool(), and keep the whole key for its message by skipping the "remotes." prefix into a separate variable.
Assisted-by: Claude Opus 5.5 Signed-off-by: Thomas Bachem <mail@thomasbachem.com> --- remote.c | 5 ++++- t/t5506-remote-groups.sh | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/remote.c b/remote.c index 024cfc547d..4bd23ddac9 100644 --- a/remote.c +++ b/remote.c @@ -2191,8 +2191,11 @@ int get_remote_group(const char *key, const char *value, void *priv) { struct remote_group_data *g = priv; + const char *group; - if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) { + if (skip_prefix(key, "remotes.", &group) && !strcmp(group, g->name)) { + if (!value) + return config_error_nonbool(key); /* split list by white space */ while (*value) { size_t wordlen = strcspn(value, " \t\n"); diff --git a/t/t5506-remote-groups.sh b/t/t5506-remote-groups.sh index 16e9a1bc2f..f11eb8511e 100755 --- a/t/t5506-remote-groups.sh +++ b/t/t5506-remote-groups.sh @@ -54,6 +54,11 @@ test_expect_success 'nonexistent group produces error' ' ! repo_fetched two ' +test_expect_success 'remotes.<group> without a value is rejected' ' + test_must_fail git -c remotes.valueless fetch valueless 2>err && + test_grep "missing value for .remotes.valueless." err +' + test_expect_success 'updating group updates all members (remote update)' ' mark group-all && update_repos &&
-- gitgitgadget