This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #1349] Return requested size for malloc_usable_sizewhen MALLOC_CHECK_ > 0
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: Andreas Jaeger <aj at suse dot com>, libc-alpha at sourceware dot org
- Date: Tue, 4 Sep 2012 20:10:36 +0530
- Subject: Re: [PATCH][BZ #1349] Return requested size for malloc_usable_sizewhen MALLOC_CHECK_ > 0
- References: <20120831113205.2a75668a@spoyarek><5040B03E.2070903@suse.com><20120831183207.79c2b4fd@spoyarek>
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