From f1dfbd9ee010e5cdf0d931d16b4b2892b33331e5 Mon Sep 17 00:00:00 2001 From: Glen Choo Date: Tue, 31 May 2022 23:12:34 +0000 Subject: remote.c: reject 0-length branch names Branch names can't be empty, so config keys with an empty branch name, e.g. "branch..remote", are silently ignored. Since these config keys will never be useful, make it a fatal error when remote.c finds a key that starts with "branch." and has an empty subsection. Signed-off-by: Glen Choo Signed-off-by: Junio C Hamano --- remote.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'remote.c') diff --git a/remote.c b/remote.c index ff04da1ec6..98c190a041 100644 --- a/remote.c +++ b/remote.c @@ -352,8 +352,12 @@ static int handle_config(const char *key, const char *value, void *cb) struct remote_state *remote_state = cb; if (parse_config_key(key, "branch", &name, &namelen, &subkey) >= 0) { + /* There is no subsection. */ if (!name) return 0; + /* There is a subsection, but it is empty. */ + if (!namelen) + return -1; branch = make_branch(remote_state, name, namelen); if (!strcmp(subkey, "remote")) { return git_config_string(&branch->remote_name, key, value); -- cgit v1.3-5-g9baa