[PATCH v3] stdio-common: Reject insufficient character data in scanf [BZ #12701]

Zack Weinberg zack@owlfolio.org
Tue Sep 2 00:08:10 GMT 2025


On Mon, Sep 1, 2025, at 5:59 PM, Maciej W. Rozycki wrote:
> On Mon, 1 Sep 2025, Florian Weimer wrote:
>> Maciej W. Rozycki wrote:
>>> Reject invalid formatted scanf character data with the 'c'
>>> conversion where there is not enough input available to satisfy the
>>> field width requested.
...
>> I don't know how common it is to use %NNNc where %NNNs was meant.
>> It may not be possible to release with this change.
...
>  It's a standards compliance bug fix and my position is that we need
>  to keep it even if it uncovers bugs in applications, especially given
>  that with the broken `%NNNc' semantics all the corner cases cannot be
>  correctly handled by the caller.

IMNSHO the entire `scanf` family should be considered unfit-for-
purpose, legacy-only interfaces; therefore, when working on them we
should prioritize keeping existing code working over basically all
other considerations, including standards compliance.  But we should
also discourage new code from using the family at all.

zw


More information about the Libc-alpha mailing list