All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Jeff King <peff@peff.net>, Elia Pinto <gitter.spiros@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 02/10] builtin/index-pack.c: convert trivial snprintf calls to xsnprintf
Date: Fri, 3 Jun 2016 16:32:41 +0100	[thread overview]
Message-ID: <5751A319.1030806@ramsayjones.plus.com> (raw)
In-Reply-To: <20160603085320.GC28401@sigill.intra.peff.net>



On 03/06/16 09:53, Jeff King wrote:
> 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.

Agreed, again I would use something like:

		char buf[GIT_SHA1_HEXSZ + 7]; /* 40 (sha1) + 4 (report) + 3 (\t\n\0) */

(and yes yuck - is report ever likely to increase? "bitmap" perhaps?)

ATB,
Ramsay Jones

  reply	other threads:[~2016-06-03 15:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-03  7:47 [PATCH 01/10] builtin/commit.c: convert trivial snprintf calls to xsnprintf Elia Pinto
2016-06-03  7:47 ` [PATCH 02/10] builtin/index-pack.c: " Elia Pinto
2016-06-03  8:53   ` Jeff King
2016-06-03 15:32     ` Ramsay Jones [this message]
2016-06-03 17:10       ` Jeff King
2016-06-03  7:47 ` [PATCH 03/10] builtin/tag.c: " Elia Pinto
2016-06-03  8:52   ` Jeff King
2016-06-03 15:37     ` Ramsay Jones
2016-06-03  7:47 ` [PATCH 04/10] combine-diff.c: " Elia Pinto
2016-06-03  8:54   ` Jeff King
2016-06-03  7:47 ` [PATCH 05/10] compat/inet_ntop.c: " Elia Pinto
2016-06-03  7:47 ` [PATCH 06/10] diff.c: " Elia Pinto
2016-06-03  9:03   ` Jeff King
2016-06-03  7:47 ` [PATCH 07/10] fast-import.c: " Elia Pinto
2016-06-03  7:47 ` [PATCH 08/10] refs.c: " Elia Pinto
2016-06-03  7:47 ` [PATCH 09/10] transport-helper.c: " Elia Pinto
2016-06-03  7:47 ` [PATCH 10/10] wrapper.c: " Elia Pinto
2016-06-03  9:13   ` Jeff King
2016-06-03  8:49 ` [PATCH 01/10] builtin/commit.c: " Jeff King
2016-06-03  9:04   ` Jeff King
2016-06-03 15:25   ` Ramsay Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5751A319.1030806@ramsayjones.plus.com \
    --to=ramsay@ramsayjones.plus.com \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.