Bug 155581

Summary: vsscanf failed to convert long string
Product: Other Reporter: yeger00
Component: OtherAssignee: other_other
Status: NEW ---    
Severity: low CC: adobriyan
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.7 Subsystem:
Regression: No Bisected commit-id:

Description yeger00 2016-08-30 06:55:21 UTC
Hello,
When using vsscanf to convert string to int, it uses simple_strtol, and it fails to convert if the string is longer then 16 bytes. 


Example code:

const char hexstring[] = "deadbeef10203040b0", *pos = hexstring;
unsigned char val[9];
size_t count = 0;

for(count = 0; count < sizeof(val)/sizeof(val[0]); count++) {
	sscanf(pos, "%2hhx", &val[count]);
	pos += 2;
}

/* val will be 00adbeef10203040b0 instead of deadbeef10203040b0. */

Thank you
Comment 1 Alexey Dobriyan 2016-09-01 10:09:51 UTC
confirmed, glibc scans "deadbeef...".