replace unchecked snprintf calls with heap buffers
commit5b1ef2cef4ff9d3213ec81465b99affb4a7c8083
authorJeff King <peff@peff.net>
Tue, 28 Mar 2017 19:46:50 +0000 (28 15:46 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Mar 2017 21:59:50 +0000 (30 14:59 -0700)
treedca13ceebc0aadd97f91bfcab3299407a10e6523
parent446d5d911214fd3d61921478c98d4a88f84e410c
replace unchecked snprintf calls with heap buffers

We'd prefer to avoid unchecked snprintf calls because
truncation can lead to unexpected results.

These are all cases where truncation shouldn't ever happen,
because the input to snprintf is fixed in size. That makes
them candidates for xsnprintf(), but it's simpler still to
just use the heap, and then nobody has to wonder if "100" is
big enough.

We'll use xstrfmt() where possible, and a strbuf when we need
the resulting size or to reuse the same buffer in a loop.

Signed-off-by: Jeff King <peff@peff.net>
bisect.c
builtin/index-pack.c
builtin/notes.c
builtin/rev-parse.c