From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id 44A6B3858D35 for ; Wed, 7 Oct 2020 18:08:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44A6B3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fw@deneb.enyo.de Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1kQDrB-0002ri-DE; Wed, 07 Oct 2020 18:08:05 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1kQDrB-00012V-9a; Wed, 07 Oct 2020 20:08:05 +0200 From: Florian Weimer To: Szabolcs Nagy via Libc-alpha Subject: Re: [PATCH] Fix aliasing violation in __vfscanf_internal [BZ #26690] References: <20201007175049.32564-1-szabolcs.nagy@arm.com> Date: Wed, 07 Oct 2020 20:08:05 +0200 In-Reply-To: <20201007175049.32564-1-szabolcs.nagy@arm.com> (Szabolcs Nagy via Libc-alpha's message of "Wed, 7 Oct 2020 18:50:49 +0100") Message-ID: <87lfgh52pm.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Oct 2020 18:08:08 -0000 * Szabolcs Nagy via Libc-alpha: > diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c > index 95b46dcbeb..d832493623 100644 > --- a/stdio-common/vfscanf-internal.c > +++ b/stdio-common/vfscanf-internal.c > @@ -135,6 +135,16 @@ > > #include "printf-parse.h" /* Use read_int. */ > > +/* Same as read_int, but for CHAR_T * instead of UCHAR_T * string. */ > +static int > +read_int_char (const CHAR_T * *pstr) > +{ > + const UCHAR_T *ustr = (const UCHAR_T *) *pstr; > + int retval = read_int (&ustr); > + *pstr = (const CHAR_T *) ustr; > + return retval; > +} > + > #define encode_error() do { \ > __set_errno (EILSEQ); \ > goto errout; \ > @@ -486,7 +496,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, > /* Check for a positional parameter specification. */ > if (ISDIGIT ((UCHAR_T) *f)) > { > - argpos = read_int ((const UCHAR_T **) &f); > + argpos = read_int_char (&f); > if (*f == L_('$')) > ++f; > else > @@ -522,7 +532,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, > /* Find the maximum field width. */ > width = 0; > if (ISDIGIT ((UCHAR_T) *f)) > - width = read_int ((const UCHAR_T **) &f); > + width = read_int_char (&f); > got_width: > if (width == 0) > width = -1; Patch and commit message look reasonable to me. Thanks.