Bug 6453 - scanf integer overflow handling different between 32bit and 64bit
Summary: scanf integer overflow handling different between 32bit and 64bit
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-24 13:10 UTC by Marcus Meissner
Modified: 2014-07-03 11:35 UTC (History)
2 users (show)

See Also:
Host: ppc-linux-gnu
Target: ppc-linux-gnu
Build: ppc-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments
foo.c (239 bytes, text/plain)
2008-04-24 13:10 UTC, Marcus Meissner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Meissner 2008-04-24 13:10:09 UTC
Matthias Andre has reported to SUSE a difference in integer handling in scanf()
handling.

The attached testcase has different results for 32bit and 64bit mode, even 
though "int" is 32bit signed in both modes (x86_64 and ppc confirmed).

$ gcc -O2 -o foo foo.c -m32
$ ./foo
s="18446744073709551615", n=1, i=2147483647, errno=34/Numerical result out of 
range
s="4294967295", n=1, i=2147483647, errno=34/Numerical result out of range
s="2147483647", n=1, i=2147483647, errno=0/Success
$ gcc -O2 -o foo foo.c -m64
$ ./foo
s="18446744073709551615", n=1, i=-1, errno=34/Numerical result out of range
s="4294967295", n=1, i=-1, errno=0/Success
s="2147483647", n=1, i=2147483647, errno=0/Success
$


Expected: same output.
Comment 1 Marcus Meissner 2008-04-24 13:10:35 UTC
Created attachment 2717 [details]
foo.c

testcase
Comment 2 Andreas Schwab 2008-04-24 14:23:23 UTC
7.19.6.2#10: ... if the result of the conversion cannot be represented in the 
object, the behavior is undefined.