From: Jeff King <peff@peff.net>
To: Han-Wen Nienhuys <hanwen@google.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git <git@vger.kernel.org>, Han-Wen Nienhuys <hanwenn@gmail.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 3/6] fixup! reftable: rest of library
Date: Tue, 1 Dec 2020 06:57:09 -0500 [thread overview]
Message-ID: <X8YvlS29KKYje1Az@coredump.intra.peff.net> (raw)
In-Reply-To: <CAFQ2z_M3C=mCkiPxOLhBSrXR-PDQdb7GLPRWM2egV4cO4a-c0w@mail.gmail.com>
On Tue, Dec 01, 2020 at 12:10:14PM +0100, Han-Wen Nienhuys wrote:
> > I think passing:
> >
> > sizes_to_segments(&seglen, NULL, 0);
> >
> > may make the code more obvious. Unlike system functions like memcpy(),
> > we can be assured of whether our functions avoid looking at a
> > zero-length array (and size_to_segments does follow that rule).
> >
> > This function, of course, is nonsense that real code would not do, and
>
> This test was added because 'real' code did this. In particular, if
> you initialize a stack of reftables, the stack has zero elements. The
> test was for the following bugfix
>
> https://github.com/google/reftable/commit/b2e42ecb54e413e494c1fcc13c21e24422645007
>
> Changing the array size to 1 here also prevents Valgrind to mark a
> regression as a OOB write.
Sorry to be unclear. I meant that real code would not allocate a static
zero-length array (though it might do so on the heap). I agree that
making sure the function behaves in the 0-segment case is quite
reasonable.
Passing NULL actually makes the test more rigorous IMHO (because it is a
strict superset of failure modes, and is something an actual caller
might do if it were dynamically growing an array that started at NULL).
-Peff
next prev parent reply other threads:[~2020-12-01 11:59 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-28 6:44 [PATCH 0/6] Minimal patches to let reftable pass the CI builds Johannes Schindelin via GitGitGadget
2020-11-28 6:44 ` [PATCH 1/6] fixup! reftable: rest of library Johannes Schindelin via GitGitGadget
2020-12-01 14:32 ` Han-Wen Nienhuys
2020-12-02 10:57 ` Johannes Schindelin
2020-12-02 18:31 ` Reftable locking on Windows (Re: [PATCH 1/6] fixup! reftable: rest of library) Han-Wen Nienhuys
2020-12-03 12:24 ` Ævar Arnfjörð Bjarmason
2020-12-03 13:56 ` Han-Wen Nienhuys
2020-11-28 6:44 ` [PATCH 2/6] fixup! reftable: utility functions Johannes Schindelin via GitGitGadget
2020-11-28 6:44 ` [PATCH 3/6] fixup! reftable: rest of library Johannes Schindelin via GitGitGadget
2020-12-01 10:26 ` Jeff King
2020-12-01 11:10 ` Han-Wen Nienhuys
2020-12-01 11:57 ` Jeff King [this message]
2020-11-28 6:44 ` [PATCH 4/6] " Johannes Schindelin via GitGitGadget
2020-11-28 6:44 ` [PATCH 5/6] " Johannes Schindelin via GitGitGadget
2020-11-28 6:44 ` [PATCH 6/6] " Johannes Schindelin via GitGitGadget
2020-12-01 10:28 ` Jeff King
2020-12-01 14:24 ` Johannes Schindelin
2020-12-02 1:50 ` Jeff King
2020-12-02 11:01 ` Han-Wen Nienhuys
2020-12-02 12:43 ` Jeff King
2020-11-30 14:26 ` [PATCH 0/6] Minimal patches to let reftable pass the CI builds Han-Wen Nienhuys
2020-12-01 14:18 ` Johannes Schindelin
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=X8YvlS29KKYje1Az@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=hanwen@google.com \
--cc=hanwenn@gmail.com \
--cc=johannes.schindelin@gmx.de \
/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).