From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] upload-pack: don't send null character in abort message to the client
Date: Mon, 26 Feb 2024 09:49:02 -0800 [thread overview]
Message-ID: <xmqqttlvnmk1.fsf@gitster.g> (raw)
In-Reply-To: <20240225183452.1939334-1-szeder.dev@gmail.com> ("SZEDER Gábor"'s message of "Sun, 25 Feb 2024 19:34:52 +0100")
SZEDER Gábor <szeder.dev@gmail.com> writes:
> Since 583b7ea31b (upload-pack/fetch-pack: support side-band
> communication, 2006-06-21) the abort message sent by upload-pack in
> case of possible repository corruption ends with a null character.
It is so so old that makes me wonder if it is safe to "fix" it, but
I cannot think of a sensible way to write a third-party client that
may have been working fine and would break when this fix is made.
> This can be seen in several test cases in 't5530-upload-pack-error.sh'
> where 'grep <pattern> output.err' often reports "Binary file
> output.err matches" because of that null character.
>
> The reason for this is that the abort message is defined as a string
> literal, and we pass its size to the send function as
> sizeof(abort_msg), which also counts the terminating null character.
>
> Use strlen() instead to avoid sending that terminating null character.
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
> upload-pack.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/upload-pack.c b/upload-pack.c
> index 2537affa90..6e0d441ef5 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -463,7 +463,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
>
> fail:
> free(output_state);
> - send_client_data(3, abort_msg, sizeof(abort_msg),
> + send_client_data(3, abort_msg, strlen(abort_msg),
> pack_data->use_sideband);
> die("git upload-pack: %s", abort_msg);
> }
prev parent reply other threads:[~2024-02-26 17:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 18:34 [PATCH] upload-pack: don't send null character in abort message to the client SZEDER Gábor
2024-02-26 17:49 ` Junio C Hamano [this message]
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=xmqqttlvnmk1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.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.
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).