]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/index-pack.c
replace unchecked snprintf calls with heap buffers
[thirdparty/git.git] / builtin / index-pack.c
index f4af2ab37ab66a118c4cdd72354b53e921a10763..197c51912d96bd0d5cbe9f34bbc8da3f2d2623c6 100644 (file)
@@ -1443,10 +1443,11 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
        if (!from_stdin) {
                printf("%s\n", sha1_to_hex(sha1));
        } else {
-               char buf[48];
-               int len = snprintf(buf, sizeof(buf), "%s\t%s\n",
-                                  report, sha1_to_hex(sha1));
-               write_or_die(1, buf, len);
+               struct strbuf buf = STRBUF_INIT;
+
+               strbuf_addf(&buf, "%s\t%s\n", report, sha1_to_hex(sha1));
+               write_or_die(1, buf.buf, buf.len);
+               strbuf_release(&buf);
 
                /*
                 * Let's just mimic git-unpack-objects here and write