Bug 203919 - sscanf - bad hex conversion value with sign bit set and %i conversion
sscanf - bad hex conversion value with sign bit set and %i conversion
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: glibc (Show other bugs)
4.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-24 10:31 EDT by Rod Swenson
Modified: 2016-11-24 10:03 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-24 10:50:23 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Rod Swenson 2006-08-24 10:31:38 EDT
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):
RHEL4 U2

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 10:31:50 EDT
Created attachment 134817 [details]
sscanf test case
Comment 2 Jakub Jelinek 2006-08-24 10:50:23 EDT
Please read the standard:
http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html
http://www.opengroup.org/onlinepubs/009695399/functions/strtol.html
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.