From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id 6A1E93858038 for ; Wed, 18 Aug 2021 16:30:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A1E93858038 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id D793D3F3062F; Wed, 18 Aug 2021 09:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1629304199; bh=2R5GYhcM7vaFNYtvZ4lgJIuMKcyTec234oetHs1KS4Q=; h=From:To:Subject:In-Reply-To:References:Date:From; b=ETz1i7Ez2Is70SqVbHcIFbHoI4vvxQW5+xEdy/ESHy4FloUHS+9mymWFTqXKYWeOo JBiBIWm3rYrOmD6KPbI3z5lVjIjUFxbfCAnyV+DOhqiwODPikTdZ5OROBQJLlRPF7J P5RNGTdqH/CuLGjhdn4shCTvux4e8LuobhgidYacxCJl6thhpAjqGpUz2MVsdv2rlv gkXQOi0vu6V6JdCd/GPTvcNcBcua2xJPAzvo8oqDjBaUSoVxCd6s/gvGiXednqPRo8 X0YzCJpGz1dAA6p6q1g3AjIr2JqHmAUn8VxUEjd9g37rtWfNHJ3tooqhezcMooJIAO ccK1bLb3H1/Zg== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PMY7mQLMKzZj; Wed, 18 Aug 2021 09:29:55 -0700 (PDT) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 1FE703F3062E; Wed, 18 Aug 2021 09:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1629304195; bh=2R5GYhcM7vaFNYtvZ4lgJIuMKcyTec234oetHs1KS4Q=; h=From:To:Subject:In-Reply-To:References:Date:From; b=qk8uXi1c5idhi9KuG8es/OZchMWmHn3+9bmjv/jDkQ+QetHSLloutMFXnlMKMkXJA e2azwDrJnvpMqyDDQrXowpSWvt40JmMX9Xnl7ajLH9OOHW8wwSYO9GDXrVDqolSzJ6 E/Zr1JrERshOZEqzSPU9WEkvF7bUu9ekjhvsTmXgdHdw7thGoulNoO1oDs8Bt+/dgL Hi3cDlU8Msy6E+9CWHwdN6D9Do6jnwCU0Zm6VorZkm2BPElfjOxlbOzV/1iGV2EGWa 1SewSzk4nuBraOPH0Rktz0VSQhMOr5gfrsoHYJnCwnvueTe0bRhPEEnwgqiEqMvWGk Q1PbUylYPRg8g== Received: by keithp.com (Postfix, from userid 1000) id 83DBA1E6011A; Wed, 18 Aug 2021 09:30:17 -0700 (PDT) From: Keith Packard To: Corinna Vinschen , newlib@sourceware.org Subject: Re: [PATCH] svfwscanf: Simplify _sungetwc_r to eliminate apparent buffer overflow In-Reply-To: References: <874kbnevjm.fsf@keithp.com> Date: Wed, 18 Aug 2021 09:30:17 -0700 Message-ID: <87bl5ud8bq.fsf@keithp.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 16:30:33 -0000 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Corinna Vinschen writes: > LGTM. Under the unlikely assumption that wscanf gets extended in future > and has to ungetc a char different from the input char, how do we catch > that? Do we need a hint, somehow, somewhere? I can't imagine a case where that wouldn't be a bug; the only reason I know that ungetc takes the old char is because stdio might not still have it in the buffer, and that can't happen for string sources. However, I also don't know how we'd catch this bug at compile time, and having the string source work differently in this case than the file source means testing using string sources might not uncover a bug that would appear with file sources. A reasonable alternative would be to have the wchar_t version call the char version multiple times, instead of just doing it inline; that would avoid any semantic difference, which seems like a feature. I'll post a patch that does it this way shortly and see which you prefer. =2D-=20 =2Dkeith --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmEdNZkACgkQ2yIaaQAA ABHLhA/+KO6wggwtnjHaCFdn/50fklSwxv8YQgpuLqiMRdbIluXq5a6kDRgFYPBM RrAKeZHpe82JPl9vqzFSZfNmN0bZKO4dpSckYz1KXvZDDEP6sSZspEGFNTY+v8FT 90cOz65KPiD68kP26yfyc4qZeAYhmVJ8YOxWF9QAgVn8usw874q5VPsgfrny4TTt P0qf7sRl3wNjdXvdiAr+X5Mo5UlU4tvzwVXGUTJfhaep+LaT6JN8ar/FgxnRY3qg RN2e+9vsq3A2hmgDWDUIQUQebeot6nchPneaQcs2ORJs9w0eBL6khAERuCxXFv5a 3cFiDsYT0X66IG2VbBwQNHwaawuBfHNqGDpBAiZJCcWe41y3RwLCYkjVW/ktMbC7 CsXLPKlQBpbQv8RzfgR2YTih1NifsRqWi2ADJPgEeOJFPYDJV3l3kZb8o1xf+poa 2GdXiqfkv3hqxhZvpSI3wPGcXj/0Q1ZWDpgeStOcuaqWNaFePn8FqJvQyDBSrFNV dPPdgGUndgRtSWGSY6E+eMQsxJPhLH8+3Pt3bR/3WeN5Fh1uiIVjFNcpbaNOzQWy 2X59i/EEihrDOZBM46GaoyEcDFfsujVqYrXPL3R2mk70oOEKH1GE4MyoUFuckul1 inEvhoPxXAZAUqOM32UXKfUtXYZowmPh3wLhriXb4FNEncGq8RY= =TOho -----END PGP SIGNATURE----- --=-=-=--