This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: US-CERT Vulnerability Note VU#162289
- From: <Gerald dot Williams at infineon dot com>
- To: <rcs at cert dot org>, <gcc at gcc dot gnu dot org>
- Cc: <crd at cert dot org>
- Date: Wed, 9 Apr 2008 21:31:27 +0200
- Subject: RE: US-CERT Vulnerability Note VU#162289
- References: <47FBA0B0.2060301@cert.org>
Robert C. Seacord wrote:
> void f(char *buf) {
> unsigned int len = len = 0xFFFFFF00;
>
> if (buf+len < buf) puts("true");
>
> }
You need to be more precise. That is not the same example
that you quoted for GCC.
In fact, if you vary the criteria too much, you will find
situations where GCC already behaved that way. The test in
the following example is optimized out by old versions of
GCC (certainly my version 3.4.5 compiler does it, with no
warnings even when using -Wall):
int f(char *buf, int i)
{
i = 1<<30;
if ((int)buf + i < (int)buf)
return 0;
return 1;
}
That's quite a bit less changed than your example, which
brings unsigned-ness into the picture. [This is exactly
the problem--signed overflow and pointer overflow aren't
defined, unlike unsigned overflow.]
Given that current Microsoft compilers reportedly exhibit
this behavior, it sounds like the advisory is going to at
least need some significant rewriting. :-)
-Jerry