From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: [musl] [C23 const 0/2] some interfaces become type-generic
Date: Thu, 25 May 2023 16:44:58 +0200 [thread overview]
Message-ID: <cover.1684932942.git.Jens.Gustedt@inria.fr> (raw)
In C23, some interfaces become type-generic with the aim that they
respect the const-contract for their pointer parameters.
With the functions alone, non-qualified pointers of buffers that are
`const`-qualified can escape. The type-generic functions/macros at an
additional security here, that compilers may then check.
This code needs `_Generic`, so it only works for compilers with at
least C11. Other compilers should still see the function interfaces as
before.
Jens Gustedt (2):
C23: change bsearch to a macro that respects the const contract
C23: change string.h and wchar.h interfaces to macros that respects
the const contract
include/stdlib.h | 12 +++++++++-
include/string.h | 54 ++++++++++++++++++++++++++++++++++++++-----
include/wchar.h | 55 +++++++++++++++++++++++++++++++++++++++-----
src/include/stdlib.h | 2 ++
src/include/string.h | 6 +++++
src/include/wchar.h | 6 +++++
src/stdlib/bsearch.c | 2 +-
src/string/memchr.c | 2 +-
src/string/strchr.c | 2 +-
src/string/strpbrk.c | 2 +-
src/string/strrchr.c | 2 +-
src/string/strstr.c | 2 +-
src/string/wcschr.c | 2 +-
src/string/wcspbrk.c | 2 +-
src/string/wcsrchr.c | 2 +-
src/string/wcsstr.c | 2 +-
src/string/wmemchr.c | 2 +-
17 files changed, 133 insertions(+), 24 deletions(-)
--
2.34.1
next reply other threads:[~2023-05-25 14:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 14:44 Jens Gustedt [this message]
2023-05-25 14:44 ` [musl] [C23 const 1/2] C23: change bsearch to a macro that respects the const contract Jens Gustedt
2023-05-26 11:29 ` Nat!
2023-05-26 17:20 ` NRK
2023-05-26 19:29 ` Jₑₙₛ Gustedt
2023-05-26 20:09 ` Rich Felker
2023-05-27 7:51 ` Jₑₙₛ Gustedt
2023-05-25 14:45 ` [musl] [C23 const 2/2] C23: change string.h and wchar.h interfaces to macros " Jens Gustedt
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=cover.1684932942.git.Jens.Gustedt@inria.fr \
--to=jens.gustedt@inria.fr \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).