Skip to content

Commit 9871824

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 614b195 commit 9871824

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

fast-import.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,9 +1237,7 @@ static void stream_blob(uintmax_t len, unsigned char *sha1out, uintmax_t mark)
12371237
sha1file_checkpoint(pack_file, &checkpoint);
12381238
offset = checkpoint.offset;
12391239

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;
12431241

12441242
git_SHA1_Init(&c);
12451243
git_SHA1_Update(&c, out_buf, hdrlen);

0 commit comments

Comments
 (0)