On Thu, Sep 30, 2010 at 03:06:30AM +0400, Dmitry V. Levin wrote:
> On Wed, Sep 29, 2010 at 11:57:19PM +0200, Lubomir Rintel wrote:
[...]
> > -   if (!outstr)
> > +   if (!outstr && (INT_MAX - sizeof "\"...\"") / 4 > max_strlen)
> >             outstr = malloc(4 * max_strlen + sizeof "\"...\"");

BTW, your check is too restrictive: it may reject legitimate values like
(INT_MAX - sizeof "\"...\"") / 4
For example, if INT_MAX==2147483647, then 536870910 would be unjustly
rejected.

> I'd prefer to check the argument that is going to be passed to malloc(3).
> For example,
>       if (!outstr) {
>               size_t malloc_size = 4 * max_strlen + sizeof "\"...\"";
>               if (malloc_size >= sizeof "\"...\"" &&
>                   (malloc_size - sizeof "\"...\"") / 4 == max_strlen)
>                       outstr = malloc(malloc_size);


-- 
ldv

Attachment: pgpINYz41yXrr.pgp
Description: PGP signature

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to