]> git.ipfire.org Git - thirdparty/git.git/commit - abspath.c
Prevent buffer overflows when path is too long
authorAntoine Pelisse <apelisse@gmail.com>
Sat, 14 Dec 2013 11:31:16 +0000 (12:31 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Dec 2013 22:06:19 +0000 (14:06 -0800)
commitfc2b6214542a46f97d7067b2f7df530ed37737a7
tree9cccda70e6bd31c1a33880ca18e239c2eb8f89bf
parentd7aced95cd681b761468635f8d2a8b82d7ed26fd
Prevent buffer overflows when path is too long

Some buffers created with PATH_MAX length are not checked when being
written, and can overflow if PATH_MAX is not big enough to hold the
path.

Replace those buffers by strbufs so that their size is automatically
grown if necessary. They are created as static local variables to avoid
reallocating memory on each call. Note that prefix_filename() returns
this static buffer so each callers should copy or use the string
immediately (this is currently true).

Reported-by: Wataru Noguchi <wnoguchi.0727@gmail.com>
Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
abspath.c
diffcore-order.c
unpack-trees.c