[PATCH v2 06/14] stdio-common: Reject insufficient character data in scanf [BZ #12701]

Maciej W. Rozycki macro@redhat.com
Tue Aug 19 17:48:24 GMT 2025


On Fri, 15 Aug 2025, Adhemerval Zanella Netto wrote:

> > Index: glibc/localedata/tst-bz12701-lc.c
> > ===================================================================
> > --- /dev/null
> > +++ glibc/localedata/tst-bz12701-lc.c
[...]
> > +  memcpy (ntfi.buffer, s, sizeof (s));
> > +
> > +  ic = i = 0;
> > +  f = fmemopen (b, sizeof (s), "r");
> 
> Add a TEST_VERIFY_EXIT (f != NULL);

 I chose to instead call:

  if (f == NULL)
    FAIL_EXIT1 ("fmemopen: %m");

just as with 01/14, as strictly speaking the invocation of `fmemopen' is 
not a part of the test proper, and this will produce useful output as to 
what went wrong.  Ultimately I think it should land in support/xfmemopen.c 
analogously to `xfclose', etc., but that can be a separate change.

> > +  TEST_VERIFY_EXIT (ftell (f) == 3);
> > +  TEST_VERIFY_EXIT (feof (f) != 0);
> > +
> > +  fclose (f);
> 
> Use xfclose.

 Right, and that implementation does exactly what I chose for `fmemopen' 
too, making me feel it's the right approach.

 I've applied both fixes throughout and posted v3 of this change only, in 
case anyone has anything else to add.  Otherwise I'll push that update 
along with the rest of the patches still outstanding once 48h have passed.

 Thank you for your review.

  Maciej



More information about the Libc-alpha mailing list