sha1_get_pack_name: use a strbuf
commitac5190cc48bd75586566ccc052304d40bbc63147
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:07:34 +0000 (24 17:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Sep 2015 17:18:18 +0000 (25 10:18 -0700)
tree2d1958c32b8395c45a9eff2b377271b2ee404f34
parent54ba4c5fa2d7de216ca090ac2e657728462c81d5
sha1_get_pack_name: use a strbuf

We do some manual memory computation here, and there's no
check that our 60 is not overflowed by the raw sprintf (it
isn't, because the "which" parameter is never longer than
"pack"). We can simplify this greatly with a strbuf.

Technically the end result is not identical, as the original
took care not to rewrite the object directory on each call
for performance reasons.  We could do that here, too (by
saving the baselen and resetting to it), but it's not worth
the complexity; this function is not called a lot (generally
once per packfile that we open).

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