From: Junio C Hamano <gitster@pobox.com>
To: Jiang Xin <worldhello.net@gmail.com>
Cc: Git List <git@vger.kernel.org>,
Bruno Albuquerque <bga@google.com>,
Jiang Xin <zhiyou.jx@alibaba-inc.com>
Subject: Re: [PATCH] object-info: init request_info before reading arg
Date: Mon, 03 Apr 2023 09:36:56 -0700 [thread overview]
Message-ID: <xmqqsfdg7wif.fsf@gitster.g> (raw)
In-Reply-To: <20230402130557.17662-1-worldhello.net@gmail.com> (Jiang Xin's message of "Sun, 2 Apr 2023 21:05:57 +0800")
Jiang Xin <worldhello.net@gmail.com> writes:
> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>
>
> When retrieving object info via capability "object-info", we store the
> command args into a requested_info variable, but forget to initialize
> it. Initialize the variable before use to prevent unexpected output.
Good eyes. We read the request packets to decide if we want to flip
the .size member of the structure, but the result would not make
much sense if the structure starts with a random garbage in it.
I wonder if we can tell our compilers (or runtime checker) to help
catch a mistake like this. Did you see our sanitizers complain, or
something?
Will queue. Thanks.
> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
> ---
> protocol-caps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/protocol-caps.c b/protocol-caps.c
> index 874bc815b4..94c51862c5 100644
> --- a/protocol-caps.c
> +++ b/protocol-caps.c
> @@ -79,7 +79,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
>
> int cap_object_info(struct repository *r, struct packet_reader *request)
> {
> - struct requested_info info;
> + struct requested_info info = { 0 };
> struct packet_writer writer;
> struct string_list oid_str_list = STRING_LIST_INIT_DUP;
next prev parent reply other threads:[~2023-04-03 16:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-02 13:05 [PATCH] object-info: init request_info before reading arg Jiang Xin
2023-04-03 16:36 ` Junio C Hamano [this message]
2023-04-04 1:07 ` Jiang Xin
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=xmqqsfdg7wif.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=bga@google.com \
--cc=git@vger.kernel.org \
--cc=worldhello.net@gmail.com \
--cc=zhiyou.jx@alibaba-inc.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).