]> git.ipfire.org Git - thirdparty/git.git/commit - sha1-file.c
write_loose_object: convert to strbuf
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:07:49 +0000 (17:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Oct 2015 18:08:05 +0000 (11:08 -0700)
commitd4b3d11a03c5733a37656ca2f23171be6efad7d3
tree1a4b9c14d274dc9da8eeffa85f142e9f28d011ac
parent4635768809885bb1c063bc9f9eee38e413f85f0d
write_loose_object: convert to strbuf

When creating a loose object tempfile, we use a fixed
PATH_MAX-sized buffer, and strcpy directly into it. This
isn't buggy, because we do a rough check of the size, but
there's no verification that our guesstimate of the required
space is enough (in fact, it's several bytes too big for the
current naming scheme).

Let's switch to a strbuf, which makes this much easier to
verify. The allocation overhead should be negligible, since
we are replacing a static buffer with a static strbuf, and
we'll only need to allocate on the first call.

While we're here, we can also document a subtle interaction
with mkstemp that would be easy to overlook.

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