Bug 1765 - scanf corner case (EXAMPLE 3 in 7.19.6.2/20)
Summary: scanf corner case (EXAMPLE 3 in 7.19.6.2/20)
Status: RESOLVED DUPLICATE of bug 12701
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-30 10:56 UTC by Paolo Carlini
Modified: 2018-06-12 11:16 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***