Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 25 Jan 2024 09:05:03 -0500
From: Rich Felker <dalias@...c.org>
To: Ismael Luceno <ismael@...ev.co.uk>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] fix avoidable segfault in catclose

On Thu, Jan 25, 2024 at 08:09:49AM +0100, Ismael Luceno wrote:
> catclose may be called with an invalid argument, particularly -1 may be
> returned by catopen if there's an error.
> 
> Signed-off-by: Ismael Luceno <ismael@...ev.co.uk>
> ---
>  src/locale/catclose.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/locale/catclose.c b/src/locale/catclose.c
> index 54e24dd2163b..af959a58dfb5 100644
> --- a/src/locale/catclose.c
> +++ b/src/locale/catclose.c
> @@ -8,6 +8,8 @@
>  
>  int catclose (nl_catd catd)
>  {
> +	if (catd == (nl_catd)-1)
> +		return -1;
>  	char *map = (char *)catd;
>  	munmap(map, V(map+8)+20);
>  	return 0;
> -- 
> 2.43.0

Generally in musl, we prefer to trap on UB rather than allowing
forward progress, especially when the natural default action without
special casing it is to trap.

Rich

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.