git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Derrick Stolee <stolee@gmail.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	git@vger.kernel.org, Jeff King <peff@peff.net>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH 07/17] commit: increase commit message buffer size
Date: Mon, 09 Jul 2018 10:45:33 -0700	[thread overview]
Message-ID: <xmqqva9oe20y.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <4eb44f33-ac9c-7ce2-0e53-ec6fcb4560fd@gmail.com> (Derrick Stolee's message of "Mon, 9 Jul 2018 09:09:00 -0400")

Derrick Stolee <stolee@gmail.com> writes:

> On 7/8/2018 7:36 PM, brian m. carlson wrote:
>> 100 bytes is not sufficient to ensure we can write a commit message
>> buffer when using a 32-byte hash algorithm.  Increase the buffer size to
>> ensure we have sufficient space.
>>
>> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
>> ---
>>   refs/files-backend.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/refs/files-backend.c b/refs/files-backend.c
>> index a9a066dcfb..252f835bae 100644
>> --- a/refs/files-backend.c
>> +++ b/refs/files-backend.c
>> @@ -1587,7 +1587,7 @@ static int log_ref_write_fd(int fd, const struct object_id *old_oid,
>>   	char *logrec;
>>     	msglen = msg ? strlen(msg) : 0;
>> -	maxlen = strlen(committer) + msglen + 100;
>> +	maxlen = strlen(committer) + msglen + 200;
>>   	logrec = xmalloc(maxlen);
>>   	len = xsnprintf(logrec, maxlen, "%s %s %s\n",
>>   			oid_to_hex(old_oid),
>
> nit: 100 is not enough anymore, but wasn't a very descriptive
> value. 200 may be enough now, but I'm not sure why.

As Brandon alludes to downthread, we probably should use strbuf for
things like this these days, so a preliminary clean-up to do so is
probably a welcome change to sneak in and rebase this series on top
of.

"%s %s %s\n" with old and new commit object name and the message
will be "2 * len(hash_in_hex) + 4" bytes long (counting the three
whitespaces and the terminating NUL), and Shawn's original in
6de08ae6 ("Log ref updates to logs/refs/<ref>", 2006-05-17) actually
computed this one as "strlen(...) + 2*40+4".

100 was merely me being sloppier than Shawn at 8ac65937 ("Make sure
we do not write bogus reflog entries.", 2007-01-26), preferring
being sufficient over not wasting even a single byte.

  parent reply	other threads:[~2018-07-09 17:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08 23:36 [PATCH 00/17] object_id part 14 brian m. carlson
2018-07-08 23:36 ` [PATCH 01/17] cache: update object ID functions for the_hash_algo brian m. carlson
2018-07-09  2:38   ` Jacob Keller
2018-07-09  4:05     ` Eric Sunshine
2018-07-09  4:31       ` Jacob Keller
2018-07-09 23:26         ` brian m. carlson
2018-07-08 23:36 ` [PATCH 02/17] tree-walk: replace hard-coded constants with the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 03/17] hex: switch to using the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 04/17] commit: express tree entry constants in terms of the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 05/17] strbuf: allocate space with GIT_MAX_HEXSZ brian m. carlson
2018-07-08 23:36 ` [PATCH 06/17] sha1-name: use the_hash_algo when parsing object names brian m. carlson
2018-07-08 23:36 ` [PATCH 07/17] commit: increase commit message buffer size brian m. carlson
2018-07-09 13:09   ` Derrick Stolee
2018-07-09 17:24     ` Stefan Beller
2018-07-09 17:27       ` Brandon Williams
2018-07-09 17:34         ` Junio C Hamano
2018-07-09 17:36           ` Brandon Williams
2018-07-09 17:45     ` Junio C Hamano [this message]
2018-07-09 23:39       ` brian m. carlson
2018-07-10 16:35         ` Junio C Hamano
2018-07-10 18:08         ` Ben Peart
2018-07-11  1:43           ` brian m. carlson
2018-07-11 15:36             ` Junio C Hamano
2018-07-08 23:36 ` [PATCH 08/17] refs/files-backend: use the_hash_algo for writing refs brian m. carlson
2018-07-08 23:36 ` [PATCH 09/17] builtin/update-index: convert to using the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 10/17] builtin/update-index: simplify parsing of cacheinfo brian m. carlson
2018-07-08 23:36 ` [PATCH 11/17] builtin/fmt-merge-msg: make hash independent brian m. carlson
2018-07-08 23:36 ` [PATCH 12/17] builtin/merge: switch to use the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 13/17] builtin/merge-recursive: make hash independent brian m. carlson
2018-07-08 23:36 ` [PATCH 14/17] diff: switch GIT_SHA1_HEXSZ to use the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 15/17] log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz brian m. carlson
2018-07-08 23:36 ` [PATCH 16/17] sha1-file: convert constants to uses of the_hash_algo brian m. carlson
2018-07-08 23:36 ` [PATCH 17/17] pretty: switch hard-coded constants to the_hash_algo brian m. carlson
2018-07-09  3:12 ` [PATCH 00/17] object_id part 14 Jacob Keller
2018-07-09 13:12   ` Derrick Stolee
2018-07-14 23:38     ` Michael Haggerty
2018-07-16 21:06       ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqva9oe20y.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=sandals@crustytoothpaste.net \
    --cc=stolee@gmail.com \
    --cc=sunshine@sunshineco.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).