From: Jeff King Date: Wed, 15 Mar 2017 21:29:08 GMT Subject: [PATCH 5/6] fast-import: replace fixed buffer with odb_pack_name Message-ID: <20170315212908.tw2a7fqo3kgpa33w@sigill.intra.peff.net> In-Reply-To: <20170315212617.6x57bvltinuozv4q@sigill.intra.peff.net> This removes the possibility of truncating the filename without realizing it. Signed-off-by: Jeff King --- fast-import.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fast-import.c b/fast-import.c index 6c13472c4..61be8b76e 100644 --- a/fast-import.c +++ b/fast-import.c @@ -966,15 +966,15 @@ static char *keep_pack(const char *curr_index_name) static void unkeep_all_packs(void) { - static char name[PATH_MAX]; + struct strbuf name = STRBUF_INIT; int k; for (k = 0; k < pack_id; k++) { struct packed_git *p = all_packs[k]; - snprintf(name, sizeof(name), "%s/pack/pack-%s.keep", - get_object_directory(), sha1_to_hex(p->sha1)); - unlink_or_warn(name); + odb_pack_name(&name, p->sha1, "keep"); + unlink_or_warn(name.buf); } + strbuf_release(&name); } static int loosen_small_pack(const struct packed_git *p) -- 2.12.0.613.g6e7c52a0d