]> git.ipfire.org Git - thirdparty/git.git/commit - path.c
enter_repo: convert fixed-size buffers to strbufs
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:07:45 +0000 (17:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Oct 2015 18:08:04 +0000 (11:08 -0700)
commite9ba678175da28607d57043e1363c6252880dd7f
tree8065c32ce9b8ae20d361f1e20f59067dad64e60a
parentb4600fbe071898068ef30be2766ee75880ec308b
enter_repo: convert fixed-size buffers to strbufs

We use two PATH_MAX-sized buffers to represent the repo
path, and must make sure not to overflow them. We do take
care to check the lengths, but the logic is rather hard to
follow, as we use several magic numbers (e.g., "PATH_MAX -
10"). And in fact you _can_ overflow the buffer if you have
a ".git" file with an extremely long path in it.

By switching to strbufs, these problems all go away. We do,
however, retain the check that the initial input we get is
no larger than PATH_MAX. This function is an entry point for
untrusted repo names from the network, and it's a good idea
to keep a sanity check (both to avoid allocating arbitrary
amounts of memory, and also as a layer of defense against
any downstream users of the names).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c