Bug 203919 - sscanf - bad hex conversion value with sign bit set and %i conversion
Summary: sscanf - bad hex conversion value with sign bit set and %i conversion
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: glibc
Version: 4.2
Hardware: i386
OS: Linux
Target Milestone: ---
: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
Depends On:
TreeView+ depends on / blocked
Reported: 2006-08-24 14:31 UTC by Rod Swenson
Modified: 2016-11-24 15:03 UTC (History)
2 users (show)

Clone Of:
Last Closed: 2006-08-24 14:50:23 UTC

Attachments (Terms of Use)
sscanf test case (2.02 KB, text/plain)
2006-08-24 14:31 UTC, Rod Swenson
no flags Details

Description Rod Swenson 2006-08-24 14:31:38 UTC
Description of problem:
'sscanf' does not process hex (0x) values properly if the MSB (sign) bit is set
using "%i" conversion. I suspect that the conversion routines do not parse the
value as a hex bit pattern, but convert the value to decimal thus causing an
overflow condition. This would explain why the cases in question would return
the max positive value.

Version-Release number of selected component (if applicable):

How reproducible:
test case attached. 

Steps to Reproduce:
Compile and execute test case
Additional info:

Using this test case on x86_64 the sscanf works fine.

Comment 1 Rod Swenson 2006-08-24 14:31:50 UTC
Created attachment 134817 [details]
sscanf test case

Comment 2 Jakub Jelinek 2006-08-24 14:50:23 UTC
Please read the standard:
0XFFFFFF00 is not in range of the int type (INT_MIN .. INT_MAX), so INT_MAX
should be returned.  If you want a negative number in hexadecimal notation,
write -0x100.

Note You need to log in before you can comment on or make changes to this bug.