From 6927e8cadfa996309182900c99c334e586babd16 Mon Sep 17 00:00:00 2001 From: Adam Murray Date: Fri, 4 Oct 2024 15:27:15 +1000 Subject: [PATCH] trace2: prevent segfault on config collection where no value specified When TRACE2 analytics is enabled, a git config option that has no value causes a segfault. Steps to Reproduce GIT_TRACE2=true GIT_TRACE2_CONFIG_PARAMS=status.* git -c status.relativePaths version Expected Result git version 2.46.0 Actual Result zsh: segmentation fault GIT_TRACE2=true This adds a null check to prevent the segfault and instead return the "empty config value" error. Signed-off-by: Adam Murray --- config.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.c b/config.c index a11bb85da303a7..5ae8614e78628b 100644 --- a/config.c +++ b/config.c @@ -615,6 +615,8 @@ static int config_parse_pair(const char *key, const char *value, if (!strlen(key)) return error(_("empty config key")); + if (!value || !strlen(value)) + return error(_("empty config value")); if (git_config_parse_key(key, &canonical_name, NULL)) return -1;