Bug 1765 - scanf corner case (EXAMPLE 3 in
Summary: scanf corner case (EXAMPLE 3 in
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
Depends on:
Reported: 2005-10-30 10:56 UTC by Paolo Carlini
Modified: 2018-06-12 11:16 UTC (History)
3 users (show)

See Also:
Last reconfirmed:
fweimer: security-


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
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 ***