mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] use libc-internal malloc for duplocale
@ 2022-03-13  0:21 Isaiah Poston
  2022-03-13  0:40 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Isaiah Poston @ 2022-03-13  0:21 UTC (permalink / raw)
  To: musl; +Cc: Isaiah Poston

newlocale and freelocale use __libc_malloc and __libc_free, but
duplocale uses malloc. This prevents invalid reads when locales created
by duplocale use a different malloc allocator than the internal one
(e.g. when using an LD_PRELOAD malloc tool such as valgrind).

This bug was introduced by commit
1e4204d522670a1d8b8ab85f1cfefa960547e8af.
---
 src/locale/duplocale.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/locale/duplocale.c b/src/locale/duplocale.c
index 030b64cb..5ce33ae6 100644
--- a/src/locale/duplocale.c
+++ b/src/locale/duplocale.c
@@ -3,6 +3,11 @@
 #include "locale_impl.h"
 #include "libc.h"
 
+#define malloc __libc_malloc
+#define calloc undef
+#define realloc undef
+#define free undef
+
 locale_t __duplocale(locale_t old)
 {
 	locale_t new = malloc(sizeof *new);
-- 
2.35.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-13  0:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-13  0:21 [musl] [PATCH] use libc-internal malloc for duplocale Isaiah Poston
2022-03-13  0:40 ` Rich Felker

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).