summaryrefslogtreecommitdiff
path: root/bulk-checkin.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 21:06:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-25 17:18:18 (GMT)
commitf2f026752993054c1b712b6f4ae3ff167db38cbe (patch)
tree557f8848296968069b5bdebb51057b01f12cbeef /bulk-checkin.c
parent5096d4909f9b13c7a650d9dbb7c9702ea7413566 (diff)
downloadgit-f2f026752993054c1b712b6f4ae3ff167db38cbe.zip
git-f2f026752993054c1b712b6f4ae3ff167db38cbe.tar.gz
git-f2f026752993054c1b712b6f4ae3ff167db38cbe.tar.bz2
archive-tar: use xsnprintf for trivial formatting
When we generate tar headers, we sprintf() values directly into a struct with the fixed-size header values. For the most part this is fine, as we are formatting small values (e.g., the octal format of "mode & 0x7777" is of fixed length). But it's still a good idea to use xsnprintf here. It communicates to readers what our expectation is, and it provides a run-time check that we are not overflowing the buffers. The one exception here is the mtime, which comes from the epoch time of the commit we are archiving. For sane values, this fits into the 12-byte value allocated in the header. But since git can handle 64-bit times, if I claim to be a visitor from the year 10,000 AD, I can overflow the buffer. This turns out to be harmless, as we simply overflow into the chksum field, which is then overwritten. This case is also best as an xsnprintf. It should never come up, short of extremely malformed dates, and in that case we are probably better off dying than silently truncating the date value (and we cannot expand the size of the buffer, since it is dictated by the ustar format). Our friends in the year 5138 (when we legitimately flip to a 12-digit epoch) can deal with that problem then. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bulk-checkin.c')
0 files changed, 0 insertions, 0 deletions