|
|
|
|
|
by deletes
4519 days ago
|
|
How does this check for anything??: if ( size == 0 || size > SIZE_MAX ) {...
size is not given a type, but if it is a size_t, then the comparison is constant and if statements is always false, unless size == 0. The second part is useless, since the maximum size of size_t == SIZE_MAX. |
|
This, in fact, was the source of a vulnerability in PHP [1]. (The way they 'resolved' it, uh, isn't much better.)
There is almost never a magic bullet for integer overflow. Programming secure systems requires thought.
[1] http://use.perl.org/use.perl.org/_Aristotle/journal/33448.ht...