From: NRK <email@example.com>
To: Tamir Duberstein <firstname.lastname@example.org>
Cc: Rich Felker <email@example.com>, firstname.lastname@example.org
Subject: Re: [musl] undefined behavior in fread.c
Date: Fri, 24 Feb 2023 21:13:34 +0600 [thread overview]
Message-ID: <email@example.com> (raw)
On Fri, Feb 24, 2023 at 09:42:00AM -0500, Tamir Duberstein wrote:
> We could take the lock and still avoid UB with an early return.
As Jens has pointed out, the UB in this case is the caller calling fread
with NULL - not in musl.
And on a sidenote, I've always found - especially for the various mem*
functions - accepting 0 size but not accepting NULL arg (when n is 0) to
be a poor choice. A lot of the value that accepting 0 size provides is
diminished by not accepting NULL.
And this affects more than just libc, too. Compilers like gcc/clang will
see a call like `memcmp(p, q, 0)` and will ""determine"" `p` and `q` are
non-null (which can lead to deleting any subsequent null-checks on those
But anyways, that was just a small rant.
As things currently are, *even if* musl deal with the NULL pointer - any
caller calling fread with NULL is still in danger from compilers and
needs to fix it on their side.
next prev parent reply other threads:[~2023-02-24 15:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-24 12:52 Tamir Duberstein
2023-02-24 13:34 ` Rich Felker
2023-02-24 13:53 ` Jₑₙₛ Gustedt
2023-02-24 13:55 ` NRK
2023-02-24 14:07 ` Rich Felker
2023-02-24 14:17 ` NRK
2023-02-24 14:42 ` Tamir Duberstein
2023-02-24 15:13 ` NRK [this message]
2023-02-24 16:12 ` Tamir Duberstein
2023-02-24 16:40 ` Jₑₙₛ Gustedt
2023-02-24 16:42 ` Tamir Duberstein
2023-02-24 17:00 ` Jₑₙₛ Gustedt
2023-02-24 17:07 ` enh
2023-02-24 17:32 ` Tamir Duberstein
2023-02-24 16:42 ` enh
2023-02-24 20:07 ` Rich Felker
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).