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.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL 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 C459A21567 for ; Sun, 24 Mar 2024 20:33:36 +0100 (CET) Received: (qmail 15441 invoked by uid 550); 24 Mar 2024 19:28:53 -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 15403 invoked from network); 24 Mar 2024 19:28:52 -0000 Date: Sun, 24 Mar 2024 15:33:42 -0400 From: Rich Felker To: Maks Mishin Cc: musl@lists.openwall.com Message-ID: <20240324193341.GE32430@brightrain.aerifal.cx> References: <20240324192503.16512-1-maks.mishinFZ@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240324192503.16512-1-maks.mishinFZ@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [musl] Re: [PATCH] iconv: Add check null-check for scd pointer On Sun, Mar 24, 2024 at 10:25:03PM +0300, Maks Mishin wrote: > After having been assigned to a NULL value at iconv.c:230, > pointer 'scd' is dereferenced at iconv.c:383. > > Found by RASU JSC. > > Signed-off-by: Maks Mishin > --- > src/locale/iconv.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/locale/iconv.c b/src/locale/iconv.c > index 7fb2e1ef..e0d200b8 100644 > --- a/src/locale/iconv.c > +++ b/src/locale/iconv.c > @@ -232,6 +232,8 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri > scd = (void *)cd; > cd = scd->base_cd; > } > + if (scd == NULL) return x; > + > unsigned to = extract_to(cd); > unsigned from = extract_from(cd); > const unsigned char *map = charmaps+from+1; > -- > 2.30.2 This makes iconv non-functional for non-stateful conversions. The claim by the static analysis tool is false. It is not dereferenced in the code path where it's null because in that code path, type==ISO2022_JP is never true. This tool you are using is really junk. You should stop sending untested and obviously incorrect patches to projects, and advise any projects that have accepted your patches that they may have been dangerously incorrect. Rich