From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: "Matthias Aßhauer via GitGitGadget" <gitgitgadget@gmail.com>,
git@vger.kernel.org, "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: Re: [PATCH v1.5] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add
Date: Sun, 16 Aug 2026 12:30:55 -0700 [thread overview]
Message-ID: <xmqqik599828.fsf@gitster.g> (raw)
In-Reply-To: <17e8c4e6-9eeb-4c71-9297-d8d5771217d8@web.de> ("René Scharfe"'s message of "Sun, 16 Aug 2026 19:51:32 +0200")
René Scharfe <l.s.r@web.de> writes:
> On 8/12/26 12:46 AM, Junio C Hamano wrote:
>> René Scharfe <l.s.r@web.de> writes:
>>
>>> From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>
>>>
>>> `worktree_basename` tries to read from memory before the passed `path`
>>> string, if `path` is empty (or only consists of directory separators).
>>> That results in unexpected nonsense data being returned to the caller,
>>> which can lead to issues, such as `git worktree add ""` recursively
>>> deleting the current working directory, including `.git`.
>>>
>>> Stop reading out of bounds in these cases to avoid that behaviour.
>>>
>>> This leads to `git worktree add ""` consistently exiting with the
>>> message `BUG: How come '' becomes empty after sanitization?`, which is
>>> still undesirable, but at least it doesn't result in data loss anymore.
>>>
>>> This fixes https://github.com/git-for-windows/git/issues/6346
>>>
>>> Signed-off-by: René Scharfe <l.s.r@web.de>
>>> ---
>>> How about this while we're waiting for a reroll? It implements what the
>>> commit message says, nothing more. Follows the style of the first loop.
>>
>> This one I think is obvious and clear. Why not take the authorship
>> too so that we do not have to worry about DCO?
>
> That feels unfair: Matthias did most of the work by identifying the bug
> and removing the premature subtraction from the loop doesn't seem very
> original to me. Ultimately my main concern is getting this surprisingly
> impactful bug fixed in a reasonable amount of time, though..
>
> René
If we can get Matthias sign this patch off, that would work for me,
too.
prev parent reply other threads:[~2026-08-16 19:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 11:19 [PATCH 0/2] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add Matthias Aßhauer via GitGitGadget
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-31 5:45 ` René Scharfe
2026-07-25 11:19 ` [PATCH 2/2] worktree: reject empty string Matthias Aßhauer via GitGitGadget
2026-08-02 6:26 ` René Scharfe
2026-08-02 9:58 ` René Scharfe
2026-08-11 21:34 ` [PATCH v1.5] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add René Scharfe
2026-08-11 22:46 ` Junio C Hamano
2026-08-16 17:51 ` René Scharfe
2026-08-16 19:30 ` Junio C Hamano [this message]
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=xmqqik599828.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=l.s.r@web.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox