From: Elijah Newren <newren@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] fast-import: disallow "." and ".." path components
Date: Mon, 25 Nov 2024 10:24:09 -0800 [thread overview]
Message-ID: <CABPp-BHCRmzb1LwwhZWwPc6Gs5BP-UMo6qgywcYz9pWppM06Jw@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cReWbkomYYNAY_Q+6ezukSt8sZ+Q0MP=45DY4XeS3M==w@mail.gmail.com>
On Mon, Nov 25, 2024 at 10:15 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Mon, Nov 25, 2024 at 12:58 PM Elijah Newren via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
> > If a user specified e.g.
> > M 100644 :1 ../some-file
> > then fast-import previously would happily create a git history where
> > there is a tree in the top-level directory named "..", and with a file
> > inside that directory named "some-file". The top-level ".." directory
> > causes problems. While git checkout will die with errors and fsck will
> > report hasDotdot problems, the user is going to have problems trying to
> > remove the problematic file. Simply avoid creating this bad history in
> > the first place.
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> > diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> > @@ -1466,6 +1466,9 @@ static int tree_content_set(
> > e->name = to_atom(p, n);
> > + if (!strcmp(e->name->str_dat, ".") || !strcmp(e->name->str_dat, "..")) {
> > + die("path %s contains invalid component", p);
> > + }
>
> Probably not worth a reroll, but is_dot_or_dotdot() might be usable here.
>
> (And -- style nit -- the braces could be dropped.)
Good catches, thanks. I think they are worth a reroll; I'll send one in.
next prev parent reply other threads:[~2024-11-25 18:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 17:58 [PATCH] fast-import: disallow "." and ".." path components Elijah Newren via GitGitGadget
2024-11-25 18:15 ` Eric Sunshine
2024-11-25 18:24 ` Elijah Newren [this message]
2024-11-25 19:00 ` [PATCH v2] " Elijah Newren via GitGitGadget
2024-11-26 6:57 ` Patrick Steinhardt
2024-11-27 14:24 ` Jeff King
2024-11-27 23:07 ` Junio C Hamano
2024-11-27 8:28 ` Kristoffer Haugsbakk
2024-11-27 13:23 ` Re* " Junio C Hamano
2024-11-27 19:41 ` Eric Sunshine
2024-11-28 0:36 ` [PATCH v2] CodingGuidelines: a handful of error message guidelines Junio C Hamano
2024-11-28 7:57 ` Eric Sunshine
2024-11-28 9:28 ` Junio C Hamano
2024-11-28 9:51 ` Eric Sunshine
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=CABPp-BHCRmzb1LwwhZWwPc6Gs5BP-UMo6qgywcYz9pWppM06Jw@mail.gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@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;
as well as URLs for NNTP newsgroup(s).