This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Updated buffer overflow protection patch

On Wed, Oct 27, 2004 at 01:35:19PM -0400, Diego Novillo wrote:
> > If it is not computed on-demand, then all pointers need to have object sizes
> > computed 4 values (maximum object size, maximum subobject size, minimum
> > object size, minimum subobject size).
> > 
> Yes, they do.  Much as they all have alias/points-to info even if
> they're not seemingly used.  Remember that other transformations may
> suddenly cause you to care about these attributes.


> > > Hmm?  I thought the second argument for __bos was a boolean?  We have
> > 
> > It is not, it is an integer from 0 to 3 (well, essentially a bitmask).
> > 
> Then you are lying in doc/extend.texi ;)

No, it just means you are not looking at the latest version of the patch.
I'm attaching the latest (Oct 16th, so it might not apply again if GCC
changed during past 11 days enough for it to matter).
If it doesn't apply, just ping me and I'll update it.

> What's this bit mask then?

The LS bit is object/subobject, the other bit is maximum/minimum.

> > > the capability of counting number of iterations in a loop.  If the loop
> > > is countable, you could easily deduce what would be the value of p at
> > > the end (Sebastian, Zdenek, is this correct?)
> > 
> > __bos can be used also within the loop, plus it should handle uncountable
> > loops as well.
> >
> Oh, absolutely.  In which case you'd have to fold it into -1.

If it is maximum, then -1 is unnecessary.  Say with:
char buf[64];
char *p = &buf[4];
for (i = 0; i < unknown_var; i++)
    strcpy (p, q); // __bos used here
    p += 4;
the maximum is 60, not -1.
But with minimum 0 is needed for uncountable loops.


Attachment: gcc4-chk.patch.bz2
Description: BZip2 compressed data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]