]> git.ipfire.org Git - thirdparty/git.git/commit
avoid using fixed PATH_MAX buffers for refs
authorJeff King <peff@peff.net>
Tue, 28 Mar 2017 19:46:30 +0000 (15:46 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Mar 2017 21:59:50 +0000 (14:59 -0700)
commit7f897b6f176319ec0f490d286c3fee11187d7095
tree94b0539edf7f759fefd19856f588882d0135c1df
parent1412f762e0363c126ea011682b61a8c9d7d7456f
avoid using fixed PATH_MAX buffers for refs

Many functions which handle refs use a PATH_MAX-sized buffer
to do so. This is mostly reasonable as we have to write
loose refs into the filesystem, and at least on Linux the 4K
PATH_MAX is big enough that nobody would care. But:

  1. The static PATH_MAX is not always the filesystem limit.

  2. On other platforms, PATH_MAX may be much smaller.

  3. As we move to alternate ref storage, we won't be bound
     by filesystem limits.

Let's convert these to heap buffers so we don't have to
worry about truncation or size limits.

We may want to eventually constrain ref lengths for sanity
and to prevent malicious names, but we should do so
consistently across all platforms, and in a central place
(like the ref code).

Signed-off-by: Jeff King <peff@peff.net>
builtin/checkout.c
builtin/ls-remote.c
builtin/replace.c
builtin/tag.c