[cfe-dev] Unsigned Integer Wrap and -fsanitize=integer
Jeffrey Walton
noloader at gmail.com
Tue Jul 30 04:00:52 PDT 2013
Hi All,
I'm testing a crypto library under the sanitizers. Crypto libraries
are notorious for doing clever (and sometimes undefined) things to
integers.
I'm catching a number of errors similar to below. Is (or should)
unsigned wrap be an error condition? I thought it was implementation
defined. Or is -fsanitize=integer catching signed integer overflow
(which is undefined behavior) and incorrectly reporting it?
Related: is -fsanize-integer Peng and Regehr's Integer Overflow
Checker? I'm very interested in IOC because Intel's ICC is ruthless
about removing code with undefined behavior.
Jeff
$ ./testlib
...
./crypt/sha1locl.h:255:2: runtime error: unsigned integer overflow:
11602415833421178322 + 16313194667034588172 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:256:2: runtime error: unsigned integer overflow:
13854689891680008357 + 7855820476526050265 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:257:2: runtime error: unsigned integer overflow:
7089814647387623028 + 17503132371316721671 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:257:2: runtime error: unsigned integer overflow:
6146202944994793083 + 12350673664601905734 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:259:2: runtime error: unsigned integer overflow:
17543271277370323423 + 5826006124154911379 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:261:2: runtime error: unsigned integer overflow:
15261508094756360537 + 16576356271601945904 cannot be represented in
type 'unsigned long'
./crypt/sha1locl.h:263:2: runtime error: unsigned integer overflow:
7467814761072524174 + 11287875045752437900 cannot be represented in
type 'unsigned long'
More information about the cfe-dev
mailing list