All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthias Aßhauer via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Marc Branchaud" <marcnarc@xiplink.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Matthias Aßhauer" <mha1993@live.de>
Subject: [PATCH 0/2] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add
Date: Sat, 25 Jul 2026 11:19:05 +0000	[thread overview]
Message-ID: <pull.2187.git.1784978348.gitgitgadget@gmail.com> (raw)

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

             reply	other threads:[~2026-07-25 11:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25 11:19 Matthias Aßhauer via GitGitGadget [this message]
2026-07-25 11:19 ` [PATCH 1/2] worktree: don't read out of bounds Matthias Aßhauer via GitGitGadget
2026-07-25 16:51   ` Junio C Hamano
2026-07-25 11:19 ` [PATCH 2/2] worktree: reject empty string Matthias Aßhauer via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2187.git.1784978348.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=marcnarc@xiplink.com \
    --cc=mha1993@live.de \
    --cc=pclouds@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.