Bug 11569

Summary: sscanf doesn't parse character sequence ranges properly
Product: [Retired] Red Hat Raw Hide Reporter: Jonathan Kamens <jik>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 1.0   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-05-22 04:03:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
scanf patch none

Description Jonathan Kamens 2000-05-22 03:58:42 UTC
The output of this program:

#include <stdio.h>

main()
{
  char buf[10] = {};
  int num;

  num = sscanf("012345", "%9[0-9]", buf);
  printf("num=%d, buf=\"%s\"\n", num, buf);
}

Should be:

num=1, buf="012345"

and indeed it is with glibc-2.1.2-11.  Unfortunately, with glibc-2.1.90-11,
the output is:

num=1, buf="0"

The attached patch fixes this problem.

Comment 1 Jonathan Kamens 2000-05-22 03:59:59 UTC
Created attachment 261 [details]
scanf patch

Comment 2 Jonathan Kamens 2000-05-22 04:03:59 UTC
Lest you think this isn't a big deal, note that it prevents netstat from being
able to print information about tcp or udp connections.

Comment 3 Jakub Jelinek 2000-08-24 10:30:44 UTC
Again, bugzilla not updated, fixed on 05-22