From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 9738621622 for ; Thu, 25 Jan 2024 15:05:02 +0100 (CET) Received: (qmail 21660 invoked by uid 550); 25 Jan 2024 14:02:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 21622 invoked from network); 25 Jan 2024 14:02:48 -0000 Date: Thu, 25 Jan 2024 09:05:03 -0500 From: Rich Felker To: Ismael Luceno Cc: musl@lists.openwall.com Message-ID: <20240125140503.GG4163@brightrain.aerifal.cx> References: <20240125070950.28673-1-ismael@iodev.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240125070950.28673-1-ismael@iodev.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [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 > --- > 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