From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.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: Tue, 4 Apr 2023 09:07:43 +0800	[thread overview]
Message-ID: <CANYiYbHB9AMpahiULEF=PoVG6y_ogDvVQvWY=ThKUdERmVbQyg@mail.gmail.com> (raw)
In-Reply-To: <xmqqsfdg7wif.fsf@gitster.g>
On Tue, Apr 4, 2023 at 12:36 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> 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?
I accidentally came across this issue when I wanted to implement a new
similar capability. I'm curious why adding "-Wuninitialized" or
"-Wmaybe-uninitialized" to gcc fails to spot this case.
     prev parent reply	other threads:[~2023-04-04  1:08 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
2023-04-04  1:07   ` Jiang Xin [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='CANYiYbHB9AMpahiULEF=PoVG6y_ogDvVQvWY=ThKUdERmVbQyg@mail.gmail.com' \
    --to=worldhello.net@gmail.com \
    --cc=bga@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).