[PATCH][BZ #1349] Return requested size for malloc_usable_size when MALLOC_CHECK_ > 0
Andreas Jaeger
aj@suse.com
Tue Sep 4 18:35:00 GMT 2012
On 09/04/2012 04:40 PM, Siddhesh Poyarekar wrote:
> 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
Thanks, this looks fine.
Andreas
> 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
>
--
Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
More information about the Libc-alpha
mailing list