Re: [PATCH v1.5] worktree: Fix out of bounds read that causes data loss and reject invalid empty input in worktree add
Junio C Hamano <[email protected]>
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
René Scharfe <[email protected]> writes: > On 8/12/26 12:46 AM, Junio C Hamano wrote: >> René Scharfe <[email protected]> writes: >> >>> From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <[email protected]> >>> >>> `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 <[email protected]> >>> --- >>> 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.