Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220313002155.19029-1-isaiah@ilposton.com>
Date: Sat, 12 Mar 2022 18:21:56 -0600
From: Isaiah Poston <isaiah@...oston.com>
To: musl@...ts.openwall.com
Cc: Isaiah Poston <isaiah@...oston.com>
Subject: [PATCH] use libc-internal malloc for duplocale

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

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.