Bug 1765

Summary: scanf corner case (EXAMPLE 3 in 7.19.6.2/20)
Product: glibc Reporter: Paolo Carlini <pcarlini>
Component: libcAssignee: Ulrich Drepper <drepper.fsp>
Status: RESOLVED DUPLICATE    
Severity: normal CC: fweimer, glibc-bugs, tydeman.fred
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Paolo Carlini 2005-10-30 10:56:06 UTC
Hi. I think glibc (as many other libc implementations, to be clear), doesn't
deal correctly with this corner case:

#include <stdio.h>

int main()
{
  float f = 0.0;
  char s[] = "100ergs of energy";
  
  int p = sscanf(s, "%f", &f);

  printf("%f %d\n", f, p);

  return 0;
}

It outputs "100.000000 1", and should be "0.000000 0". See EXAMPLE 3 in
7.19.6.2/20.
Comment 1 Ulrich Drepper 2005-12-23 15:36:00 UTC
This is stupidity on the ISO C committee side which goes against existing
practice.  Any change can break existing code.
Comment 2 Andreas Schwab 2018-06-12 08:00:11 UTC
*** Bug 23274 has been marked as a duplicate of this bug. ***
Comment 3 Joseph Myers 2018-06-12 11:16:01 UTC
Being tracked in bug 12701.

*** This bug has been marked as a duplicate of bug 12701 ***