Skip to content

Commit 9e6c1e9

Browse files
peffgitster
authored andcommitted
archive-tar: convert snprintf to xsnprintf
Commit f2f0267 (archive-tar: use xsnprintf for trivial formatting, 2015-09-24) converted cases of "sprintf" to "xsnprintf", but accidentally left one as just "snprintf". This meant that we could silently truncate the resulting buffer instead of flagging an error. In practice, this is impossible to achieve, as we are formatting a ustar checksum, which can be at most 7 characters. But the point of xsnprintf is to document and check for "should be impossible" conditions; this site was just accidentally mis-converted during f2f0267. Noticed-by: Paul Green <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d62c89a commit 9e6c1e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

archive-tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void prepare_header(struct archiver_args *args,
181181
memcpy(header->magic, "ustar", 6);
182182
memcpy(header->version, "00", 2);
183183

184-
snprintf(header->chksum, sizeof(header->chksum), "%07o", ustar_header_chksum(header));
184+
xsnprintf(header->chksum, sizeof(header->chksum), "%07o", ustar_header_chksum(header));
185185
}
186186

187187
static int write_extended_header(struct archiver_args *args,

0 commit comments

Comments
 (0)