]> git.ipfire.org Git - thirdparty/git.git/commit - dir.c
dir: convert to strbuf
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Tue, 1 May 2012 11:25:24 +0000 (13:25 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 May 2012 16:13:00 +0000 (09:13 -0700)
commit49dc2cc2c97cd76435d7f1609f2c573b64efd5b6
tree78ff8e6ba1fe613b517c72e85636f22335c9aaea
parentf174a2583c9f42315b60205890fa67a79a1f1669
dir: convert to strbuf

The functions read_directory_recursive() and treat_leading_path() both
use buffers sized to fit PATH_MAX characters.  The latter can be made to
overrun its buffer, e.g. like this:

$ a=0123456789abcdef
$ a=$a$a$a$a$a$a$a$a
$ a=$a$a$a$a$a$a$a$a
$ a=$a$a$a$a$a$a$a$a
$ git add $a/a

Instead of trying to add a check and potentionally forgetting to address
similar cases, convert the involved functions and their helpers to use
struct strbuf.  The patch is suprisingly large because the helpers
treat_path() and treat_one_path() modify the buffer as well and thus need
to be converted, too.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c