Skip to content

Commit

Permalink
trace2: prevent segfault on config collection where no value specified
Browse files Browse the repository at this point in the history
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 an "empty config value" error.

Signed-off-by: Adam Murray <[email protected]>
  • Loading branch information
ad-murray committed Oct 8, 2024
1 parent 777489f commit 9b505b7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 9b505b7

Please sign in to comment.