From: Jeff King Date: Fri, 03 Jun 2016 08:53:20 GMT Subject: Re: [PATCH 02/10] builtin/index-pack.c: convert trivial snprintf calls to xsnprintf Message-ID: <20160603085320.GC28401@sigill.intra.peff.net> In-Reply-To: <20160603074724.12173-2-gitter.spiros@gmail.com> On Fri, Jun 03, 2016 at 07:47:16AM +0000, Elia Pinto wrote: > diff --git a/builtin/index-pack.c b/builtin/index-pack.c > index e8c71fc..c032fe7 100644 > --- a/builtin/index-pack.c > +++ b/builtin/index-pack.c > @@ -1443,7 +1443,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name, > printf("%s\n", sha1_to_hex(sha1)); > } else { > char buf[48]; > - int len = snprintf(buf, sizeof(buf), "%s\t%s\n", > + int len = xsnprintf(buf, sizeof(buf), "%s\t%s\n", > report, sha1_to_hex(sha1)); > write_or_die(1, buf, len); So it's pretty unclear here whether that 48 is big enough (it is, if you read the whole function, because "report" is always a 4-char string). Yuck. At least there should be a comment explaining why 48 is big enough. -Peff