[PATCH][BZ #1349] Return requested size for malloc_usable_size when MALLOC_CHECK_ > 0
Siddhesh Poyarekar
siddhesh@redhat.com
Tue Sep 4 14:41:00 GMT 2012
hi,
ping?
http://sourceware.org/ml/libc-alpha/2012-08/msg00639.html
with the updated patch here:
http://sourceware.org/ml/libc-alpha/2012-08/msg00642.html
Regards,
Siddhesh
On Fri, 31 Aug 2012 18:32:07 +0530, Siddhesh wrote:
> On Fri, 31 Aug 2012 14:38:22 +0200, Andreas wrote:
> > > + memset (p, 0, malloc_usable_size (p));
> > > + free (p);
> > > + return 0;
> >
> > In this case malloc_usable_size () should return >= 7, so I suggest
> > to check for that value as well. The memset/free is a good idea!
>
> When MALLOC_CHECK_ is exported as a positive value (which I am doing
> for this test), malloc_usable_size should return exactly 7, since the
> malloc_check code adds a magic number at p[7] if p is the mem pointer.
> Anything greater than that and the user may risk writing over the
> magic value and tripping an assertion during free.
>
> But I get your point; I will add a check to ensure that usable_size ==
> 7, lest it returns a value less than 7 due to some future bug. Updated
> patch attached.
>
> Regards,
> Siddhesh
More information about the Libc-alpha
mailing list