mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Isaiah Poston <isaiah@ilposton.com>
To: musl@lists.openwall.com
Cc: Isaiah Poston <isaiah@ilposton.com>
Subject: [musl] [PATCH] use libc-internal malloc for duplocale
Date: Sat, 12 Mar 2022 18:21:56 -0600	[thread overview]
Message-ID: <20220313002155.19029-1-isaiah@ilposton.com> (raw)

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


             reply	other threads:[~2022-03-13  0:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-13  0:21 Isaiah Poston [this message]
2022-03-13  0:40 ` Rich Felker

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=20220313002155.19029-1-isaiah@ilposton.com \
    --to=isaiah@ilposton.com \
    --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).