|
Message-Id: <cover.1684932942.git.Jens.Gustedt@inria.fr> Date: Thu, 25 May 2023 16:44:58 +0200 From: Jens Gustedt <Jens.Gustedt@...ia.fr> To: musl@...ts.openwall.com Subject: [C23 const 0/2] some interfaces become type-generic 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.