On Sat, Oct 26, 2013 at 09:41:36PM +0200, Arnaud Charlet wrote:
> > Hi, as I brainstormed how prevent possible overflows in memory allocation I
> > came with heretic idea:
> >
> > For gcc -D_FORTIFY_SOURCE=2 we expand all multiplication with size_t
> > type by one that checks for integer overflow and aborts on it. This
> > would prevent most overflow at cost of breaking some legitimate
> > applications that use multiplication in clever way.
> >
> > A less heretic way that is applicable for C++ would be write a class
> > size_t overflow that would do arithmetic in saturating way and issue
> > warnings when there is a size_t multiplication.
> >
> > Comments?
>
> Or alternatively you could use the Ada language where integer overflow
> and buffer overflows are built into the language are fully handled by
> the compiler.
>
Yeah, I will suggest my boss in our project that cost $1 000 000 to
fire all C programmers, hire ada programmers instead of them and rewrite
it which will cost another $500 000.