News for hackers. Stuff that matters.
Re:Guide to Advanced Programming in C by deletes on Thursday February 06, 2014 @06:52PM (#7193769)
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.
Re:Guide to Advanced Programming in C by jwise0 on Thursday February 06, 2014 @06:56PM (#7193786)
Worse, it is not even a certain check against integer overflow. A particularly large expression could have overflowed substantially enough that it becomes positive again!

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...

Re:Guide to Advanced Programming in C by comex on Thursday February 06, 2014 @09:19PM (#7194431)
Note that since it says 'size == 0', it's not merely "not a certain check", but a check that passes for almost all overflowing values :)
Re:Guide to Advanced Programming in C by tterrace on Thursday February 06, 2014 @06:57PM (#7193791)
Re:Guide to Advanced Programming in C by pfacka on Friday February 07, 2014 @03:19AM (#7195298)
It seems that I have totally messed up whole vector example by last minute changes. The check was meant to illustrate what eliteraspberrie described in previous comment.