Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Sat, 12 Mar 2022 19:40:28 -0500
From: Rich Felker <dalias@...c.org>
To: Isaiah Poston <isaiah@...oston.com>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] use libc-internal malloc for duplocale

On Sat, Mar 12, 2022 at 06:21:56PM -0600, Isaiah Poston wrote:
> 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

Thanks! Applying.

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.