From: "Shawn O. Pearce" <spearce@spearce.org>
To: Johannes Sixt <j.sixt@viscovery.net>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 8/6 v2] receive-pack: Send internal errors over side-band #2
Date: Thu, 11 Feb 2010 07:05:47 -0800 [thread overview]
Message-ID: <20100211150547.GL2747@spearce.org> (raw)
In-Reply-To: <4B73C0FF.5020503@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> wrote:
> Shawn O. Pearce schrieb:
>> +static void report_message(const char *prefix, const char *err, va_list params)
>> +{
>> + int sz = strlen(prefix);
>> + char msg[4096];
>> +
>> + strncpy(msg, prefix, sz);
>> + sz += vsnprintf(msg + sz, sizeof(msg) - sz, err, params);
>> + if (sz > (sizeof(msg) - 1))
>> + sz = sizeof(msg) - 1;
>> + msg[sz++] = '\n';
>
> Sorry, still no joy - the terminating NUL is missing (I should have
> noticed this in your v1 already).
Why is it necessary?
Once the msg buffer is prepared, its written using its length, sz,
not its NUL termination status. Neither send_sideband() nor xwrite()
care about NUL termination.
The only reason to put a NUL onto this buffer is so you can do
"p msg" within GDB and get a useful result. We don't typically do
this in these contexts.
Or did my MTA inject additional C code I didn't write?
> I suggest to forgo the length check for
> simplicity because this function is only called with data that is already
> guaranteed to be less than 1000 bytes, i.e.:
>
> strncpy(msg, prefix, sz);
> /* data is guaranteed to fit due to packet length limit in
> read_head_info() */
Yea, that's true now. We probably could have used 1200 bytes for
the msg buffer, rather than 4096. Even the huge warnings about
current branch behavior are broken up into one string per line.
--
Shawn.
next prev parent reply other threads:[~2010-02-11 15:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 2:01 [PATCH 7/6] t5401: Use a bare repository for the remote peer Shawn O. Pearce
2010-02-10 2:01 ` [PATCH 8/6] receive-pack: Send internal errors over side-band #2 Shawn O. Pearce
2010-02-10 7:13 ` Johannes Sixt
2010-02-10 7:23 ` Junio C Hamano
2010-02-10 8:13 ` Johannes Sixt
2010-02-10 17:34 ` [PATCH 8/6 v2] " Shawn O. Pearce
2010-02-11 8:34 ` Johannes Sixt
2010-02-11 15:05 ` Shawn O. Pearce [this message]
2010-02-11 19:04 ` Johannes Sixt
2010-02-10 17:17 ` [PATCH 8/6] " Shawn O. Pearce
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=20100211150547.GL2747@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j.sixt@viscovery.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 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 NNTP newsgroup(s).