git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 00/15] Fix segfaults on settings given without a value

From
Thomas Bachem via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 7, 2026, 08:42 UTC
Message-ID
<pull.2297.git.1794040967.gitgitgadget@gmail.com>

A setting given without a value, as in "git -c foo.bar" or a bare "bar" under "[foo]", is passed as NULL to the code that reads it. In these places git does not check for that and segfaults:

 * rebase.missingCommitsCheck in "git rebase -i"
 * core.alternateRefsCommand and core.alternateRefsPrefixes in "git fetch",
   "git receive-pack" and "git rev-list --alternate-refs", in a repository
   with an alternate
 * the color slots of "git add -p", "git add -i" and the other interactive
   patch modes
 * fetch.bundleCreationToken in "git fetch" and "git clone --bundle-uri",
   with a creationToken bundle list
 * grep.patternType in "git grep", "git log" and "git show"
 * remote.*.tagOpt in "git fetch", "git remote" and "git status"
 * color.blame.repeatedLines and color.blame.highlightRecent in "git blame"
 * branch.*.mergeOptions in "git merge" on that branch
 * remotes.* in "git fetch" and "git push" of that remote group
 * safe.bareRepository in any bare repository that git discovers
 * bitmapPseudoMerge.*.pattern when writing a bitmap, as in "git repack
   -adb"
 * scalar.repo in "scalar reconfigure --all"
 * remote.*.url in nearly every command, when an includeIf
   "hasconfig:remote.*.url:..." section exists
 * mode, heuristic, uri and creationToken in a bundle list, in "git clone
   --bundle-uri" and "git fetch"
 * any key at all in "git config list --type=color" and "--type=expiry-date"

These turned up in a check of every config callback and every caller of repo_config_get_value(), and in runs of two dozen common commands with each key that "git help --config" lists set without a value. There may be more in code that neither method reached.

Most patches reject the missing value with config_error_nonbool(), as ba176db511 (config: handle NULL value when parsing non-bools, 2023-12-07) did for other settings. Three accept it without an error: a missing fetch.bundleCreationToken counts as 0 (patch 4), a remote URL without a value matches no includeIf condition (patch 13), and "git config list" leaves the key out (patch 15). The crash fixed in patch 14 can also come from a server, through a bundle list it advertises to clients that use bundle URIs. It is still a plain NULL dereference. Only patch 15 fixes a regression, which came in with 2.54.0.

remote.*.followRemoteHEAD without a value crashes the same commands. This series leaves it alone, as ch/remote-defer-follow-remote-head-validation in 'seen' already makes it safe, checking the value only where fetch uses it.

The series is based on master and merges cleanly there. In 'next' and 'seen', t5618 conflicts with iw/connected-deepen-fetch-no-alternate-refs, and in 'seen' also with kk/quarantine-alternate-refs, as each adds tests at the end of the file. Keeping both sides resolves it.

Thomas Bachem (15):
  rebase -i: handle NULL value for rebase.missingCommitsCheck
  odb: handle NULL values for core.alternateRefs* config
  add-patch: handle NULL value for color slots
  bundle-uri: handle NULL value for fetch.bundleCreationToken
  grep: handle NULL value for grep.patternType
  remote: handle NULL value for remote.<name>.tagOpt
  blame: handle NULL values for color.blame.* config
  merge: handle NULL value for branch.<name>.mergeOptions
  remote: handle NULL value for remotes.<group>
  setup: handle NULL value for safe.bareRepository
  pseudo-merge: handle NULL value for bitmapPseudoMerge.<name>.pattern
  scalar: handle NULL value for scalar.repo
  config: handle NULL value for remote URLs in hasconfig includes
  bundle-uri: handle NULL values in bundle lists
  config: handle NULL values when listing colors and expiry dates
 add-patch.c                     |  2 +-
 builtin/blame.c                 |  4 ++++
 builtin/config.c                |  4 ++--
 builtin/merge.c                 |  2 ++
 bundle-uri.c                    | 12 +++++++++++-
 config.c                        |  3 ++-
 grep.c                          |  2 ++
 odb.c                           |  4 ++--
 pseudo-merge.c                  |  4 ++++
 rebase-interactive.c            |  2 +-
 remote.c                        |  7 ++++++-
 scalar.c                        |  5 ++++-
 setup.c                         |  2 ++
 t/t0035-safe-bare-repository.sh |  6 ++++++
 t/t1300-config.sh               | 32 ++++++++++++++++++++++++++++++++
 t/t3404-rebase-interactive.sh   |  7 +++++++
 t/t3701-add-interactive.sh      | 12 ++++++++++++
 t/t5333-pseudo-merge-bitmaps.sh |  5 +++++
 t/t5505-remote.sh               |  5 +++++
 t/t5506-remote-groups.sh        |  5 +++++
 t/t5558-clone-bundle-uri.sh     | 20 ++++++++++++++++++++
 t/t5618-alternate-refs.sh       |  9 +++++++++
 t/t5750-bundle-uri-parse.sh     | 16 ++++++++++++++++
 t/t7600-merge.sh                |  6 ++++++
 t/t7810-grep.sh                 |  5 +++++
 t/t8012-blame-colors.sh         |  7 +++++++
 t/t9210-scalar.sh               |  5 +++++
 27 files changed, 183 insertions(+), 10 deletions(-)
base-commit: 6de20f6092dcf9bdb1c8efe03db4b70c82b423dd
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2297%2Fthomasbachem%2Fconfig-null-value-segfaults-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2297/thomasbachem/config-null-value-segfaults-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2297
-- 
gitgitgadget
Next: Thomas Bachem via GitGitGadget
Message 1 of 70 in “Fix segfaults on settings given without a value”
  1. 00/15 Fix segfaults on settings given without a valueThomas Bachem via GitGitGadget, Nov 7, 2026
  2. 01/15 rebase -i: handle NULL value for rebase.missingCommitsCheckThomas Bachem via GitGitGadget, Nov 7, 2026
  3. Phillip WoodNov 9, 2026
  4. Junio C HamanoNov 9, 2026
  5. Thomas BachemNov 9, 2026
  6. 02/15 odb: handle NULL values for core.alternateRefs* configThomas Bachem via GitGitGadget, Nov 7, 2026
  7. 03/15 add-patch: handle NULL value for color slotsThomas Bachem via GitGitGadget, Nov 7, 2026
  8. 04/15 bundle-uri: handle NULL value for fetch.bundleCreationTokenThomas Bachem via GitGitGadget, Nov 7, 2026
  9. Derrick StoleeNov 9, 2026
  10. 05/15 grep: handle NULL value for grep.patternTypeThomas Bachem via GitGitGadget, Nov 7, 2026
  11. 06/15 remote: handle NULL value for remote.<name>.tagOptThomas Bachem via GitGitGadget, Nov 7, 2026
  12. Phillip WoodNov 10, 2026
  13. 07/15 blame: handle NULL values for color.blame.* configThomas Bachem via GitGitGadget, Nov 7, 2026
  14. Phillip WoodNov 10, 2026
  15. 08/15 merge: handle NULL value for branch.<name>.mergeOptionsThomas Bachem via GitGitGadget, Nov 7, 2026
  16. Phillip WoodNov 10, 2026
  17. Junio C HamanoNov 10, 2026
  18. Phillip WoodNov 11, 2026
  19. Ben KnobleNov 11, 2026
  20. Junio C HamanoNov 11, 2026
  21. 09/15 remote: handle NULL value for remotes.<group>Thomas Bachem via GitGitGadget, Nov 7, 2026
  22. 10/15 setup: handle NULL value for safe.bareRepositoryThomas Bachem via GitGitGadget, Nov 7, 2026
  23. 11/15 pseudo-merge: handle NULL value for bitmapPseudoMerge.<name>.patternThomas Bachem via GitGitGadget, Nov 7, 2026
  24. 12/15 scalar: handle NULL value for scalar.repoThomas Bachem via GitGitGadget, Nov 7, 2026
  25. Derrick StoleeNov 9, 2026
  26. 13/15 config: handle NULL value for remote URLs in hasconfig includesThomas Bachem via GitGitGadget, Nov 7, 2026
  27. 14/15 bundle-uri: handle NULL values in bundle listsThomas Bachem via GitGitGadget, Nov 7, 2026
  28. Derrick StoleeNov 9, 2026
  29. 15/15 config: handle NULL values when listing colors and expiry datesThomas Bachem via GitGitGadget, Nov 7, 2026
  30. Derrick StoleeNov 9, 2026
  31. 00/15 Fix segfaults on settings given without a valueThomas Bachem via GitGitGadget, Nov 10, 2026
  32. 01/15 rebase -i: handle NULL value for rebase.missingCommitsCheckThomas Bachem via GitGitGadget, Nov 10, 2026
  33. Phillip WoodNov 10, 2026
  34. 02/15 odb: handle NULL values for core.alternateRefs* configThomas Bachem via GitGitGadget, Nov 10, 2026
  35. 03/15 add-patch: handle NULL value for color slotsThomas Bachem via GitGitGadget, Nov 10, 2026
  36. 04/15 bundle-uri: handle NULL value for fetch.bundleCreationTokenThomas Bachem via GitGitGadget, Nov 10, 2026
  37. 05/15 grep: handle NULL value for grep.patternTypeThomas Bachem via GitGitGadget, Nov 10, 2026
  38. 06/15 remote: handle NULL value for remote.<name>.tagOptThomas Bachem via GitGitGadget, Nov 10, 2026
  39. 07/15 blame: handle NULL values for color.blame.* configThomas Bachem via GitGitGadget, Nov 10, 2026
  40. 08/15 merge: handle NULL value for branch.<name>.mergeOptionsThomas Bachem via GitGitGadget, Nov 10, 2026
  41. 09/15 remote: handle NULL value for remotes.<group>Thomas Bachem via GitGitGadget, Nov 10, 2026
  42. 10/15 setup: handle NULL value for safe.bareRepositoryThomas Bachem via GitGitGadget, Nov 10, 2026
  43. 11/15 pseudo-merge: handle NULL value for bitmapPseudoMerge.<name>.patternThomas Bachem via GitGitGadget, Nov 10, 2026
  44. 12/15 scalar: handle NULL value for scalar.repoThomas Bachem via GitGitGadget, Nov 10, 2026
  45. 13/15 config: handle NULL value for remote URLs in hasconfig includesThomas Bachem via GitGitGadget, Nov 10, 2026
  46. 14/15 bundle-uri: handle NULL values in bundle listsThomas Bachem via GitGitGadget, Nov 10, 2026
  47. Phillip WoodNov 10, 2026
  48. Derrick StoleeNov 10, 2026
  49. 15/15 config: handle NULL values when listing colors and expiry datesThomas Bachem via GitGitGadget, Nov 10, 2026
  50. Phillip WoodNov 10, 2026
  51. Thomas BachemNov 10, 2026
  52. 00/15 Fix segfaults on settings given without a valueThomas Bachem via GitGitGadget, Nov 11, 2026
  53. 01/15 rebase -i: handle NULL value for rebase.missingCommitsCheckThomas Bachem via GitGitGadget, Nov 11, 2026
  54. 02/15 odb: handle NULL values for core.alternateRefs* configThomas Bachem via GitGitGadget, Nov 11, 2026
  55. 03/15 add-patch: handle NULL value for color slotsThomas Bachem via GitGitGadget, Nov 11, 2026
  56. 04/15 bundle-uri: handle NULL value for fetch.bundleCreationTokenThomas Bachem via GitGitGadget, Nov 11, 2026
  57. 05/15 grep: handle NULL value for grep.patternTypeThomas Bachem via GitGitGadget, Nov 11, 2026
  58. 06/15 remote: handle NULL value for remote.<name>.tagOptThomas Bachem via GitGitGadget, Nov 11, 2026
  59. 07/15 blame: handle NULL values for color.blame.* configThomas Bachem via GitGitGadget, Nov 11, 2026
  60. 08/15 merge: handle NULL value for branch.<name>.mergeOptionsThomas Bachem via GitGitGadget, Nov 11, 2026
  61. 09/15 remote: handle NULL value for remotes.<group>Thomas Bachem via GitGitGadget, Nov 11, 2026
  62. 10/15 setup: handle NULL value for safe.bareRepositoryThomas Bachem via GitGitGadget, Nov 11, 2026
  63. 11/15 pseudo-merge: handle NULL value for bitmapPseudoMerge.<name>.patternThomas Bachem via GitGitGadget, Nov 11, 2026
  64. 12/15 scalar: handle NULL value for scalar.repoThomas Bachem via GitGitGadget, Nov 11, 2026
  65. 13/15 config: handle NULL value for remote URLs in hasconfig includesThomas Bachem via GitGitGadget, Nov 11, 2026
  66. 14/15 bundle-uri: handle NULL values in bundle listsThomas Bachem via GitGitGadget, Nov 11, 2026
  67. 15/15 config: handle NULL values when listing colors and expiry datesThomas Bachem via GitGitGadget, Nov 11, 2026
  68. Phillip WoodNov 12, 2026
  69. Derrick StoleeNov 12, 2026
  70. Junio C HamanoNov 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.