There's a terminology problem here: the program is not incorrect, the programmer has made an incorrect assumption. The assumption is that (buf + len < buf) will be true if len is very large. Besides the fact that the assumption is false if sizeof(*buf) != 1, the GCC team (and other compilers) point out that this assumption is not warrented by the C spec. Stronger still, the C spec allows you to *assume* the test is false, no matter the value of len (assuming len is unsigned btw). That said, I'd love a way to say: if( __wraps( buf + len ) ) die();
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds