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

[PATCH 0/2] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add

From
Matthias Aßhauer via GitGitGadget <gitgitgadget@gmail.com>
Date
Jul 25, 2026, 11:19 UTC
Message-ID
<pull.2187.git.1784978348.gitgitgadget@gmail.com>

Passing an empty string to git worktree add (typically via an unset variable, e.g. git worktree add "$UNSET_VAR" -b tb origin/main) can result in BUG: How come '' becomes empty after sanitization? but it can also have worse consequences: recursively deleting the current working directory, including .git. The inconsistent behaviour is caused by worktree_basename reading unrelated bytes from the memory before path and passing that back to add_worktree, which can circumvent the check for the BUG call.

Matthias Aßhauer (2):
  worktree: don't read out of bounds
  worktree: reject empty string
 builtin/worktree.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
base-commit: 9a0c4701dcd5725c4184599322b52933ff5005ca
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2187%2Frimrul%2Fworktree-fix-oob-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2187/rimrul/worktree-fix-oob-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2187
-- 
gitgitgadget
Next: Matthias Aßhauer via GitGitGadget
Message 1 of 11 in “worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add”
  1. 0/2 worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree addMatthias Aßhauer via GitGitGadget, Jul 25, 2026
  2. 1/2 worktree: don't read out of boundsMatthias Aßhauer via GitGitGadget, Jul 25, 2026
  3. Junio C HamanoJul 25, 2026
  4. René ScharfeJul 31, 2026
  5. 2/2 worktree: reject empty stringMatthias Aßhauer via GitGitGadget, Jul 25, 2026
  6. René ScharfeAug 2, 2026
  7. René ScharfeAug 2, 2026
  8. worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree addRené Scharfe, Aug 11, 2026
  9. Junio C HamanoAug 11, 2026
  10. René ScharfeAug 16, 2026
  11. Junio C HamanoAug 16, 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.