Subject: Re: [PATCH] object-name: reject too-deep recursive ancestor queries

From: Patrick Steinhardt <[email-masked]>
Date: Fri, 24 Nov 2023 11:11:53 +0100

On Fri, Nov 24, 2023 at 06:44:33PM +0900, Junio C Hamano wrote:
> Patrick Steinhardt <[email-masked]> writes:
> 
> > I have to wonder whether we should tighten restrictions even further:
> > instead of manually keeping track of how deep in the stack we are, we
> > limit the length of revisions to at most 1MB. I would claim that this
> > limit is sufficiently large to never be a problem in practice.
> 
> Tempting.
> 
> > Revisions
> > are limited to 4kB on most platforms anyway due to the maximum path
> > length.
> 
> I do not quite get this part, though.
> 
> When we get "HEAD~~~~~~~~~^2~~~~~~" from the user, do we somehow try
> to create a file or a directory with that name and fail due to
> ENAMETOOLONG?

Sorry, this was a typo on my part. I didn't mean "revision", I meant
"reference" here. References are limited to at most 4kB on most
platforms due to filesystem limitations, whereas revisions currently
have no limits in place.

Patrick

> There are ways like "git rev-list --stdin" to cause Git read input
> lines of arbitrary length, so I do not think the command line length
> limit does not come into the picture, either.
> 
> But I do agree that the only useful use of such a revision string
> that is longer than 1MB would be to attack.
>