From: Jeff King Date: Fri, 24 Mar 2017 17:26:24 +0000 (-0400) Subject: fast-import: use xsnprintf for formatting headers X-Git-Tag: v2.13.0-rc0~54^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98718242cfd18f106dfcd7663282fb9906fd38a5;p=git 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 Signed-off-by: Junio C Hamano --- diff --git a/fast-import.c b/fast-import.c index 9ae2053a8f..87c4e7e400 100644 --- a/fast-import.c +++ b/fast-import.c @@ -1237,9 +1237,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark) sha1file_checkpoint(pack_file, &checkpoint); offset = checkpoint.offset; - hdrlen = snprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1; - if (out_sz <= hdrlen) - die("impossibly large object header"); + hdrlen = xsnprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1; git_SHA1_Init(&c); git_SHA1_Update(&c, out_buf, hdrlen);