Skip to content

Commit 28f20c2

Browse files
committed
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 <ad@canva.com>
1 parent 23d289d commit 28f20c2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ static int config_parse_pair(const char *key, const char *value,
615615

616616
if (!strlen(key))
617617
return error(_("empty config key"));
618+
if (!value || !strlen(value))
619+
return error(_("empty config value"));
618620
if (git_config_parse_key(key, &canonical_name, NULL))
619621
return -1;
620622

0 commit comments

Comments
 (0)