fast-import: use xsnprintf for formatting headers
The stream_blob() function checks the return value of snprintf and dies. This is more simply done with xsnprintf (and matches the similar call in store_object). The message the user would get is less specific, but since the point is that this _shouldn't_ ever happen, that's OK. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 24, 2017 at 13:26 UTC
98718242cfd18f106dfcd7663282fb9906fd38a5
1 file changed
+1
-3
fast-import.c
+1
-3
@@ -1237,9 +1237,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
1237
sha1file_checkpoint(pack_file, &checkpoint);
1238
offset = checkpoint.offset;
1239
1240
- hdrlen = snprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
1241
- if (out_sz <= hdrlen)
1242
- die("impossibly large object header");
1240
+ hdrlen = xsnprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
1241
1242
git_SHA1_Init(&c);
1243
git_SHA1_Update(&c, out_buf, hdrlen);