[Gluster-devel] catching unitialized structures
Anand Avati
anand.avati at gmail.com
Tue Apr 30 14:27:37 UTC 2013
On Tue, Apr 30, 2013 at 7:24 AM, Jeff Darcy <jdarcy at redhat.com> wrote:
> On 04/30/2013 07:31 AM, Vijay Bellur wrote:
>
>> On 04/30/2013 06:10 AM, Jeff Darcy wrote:
>>
>>> On 04/29/2013 01:38 PM, Vijay Bellur wrote:
>>>
>>>> There are a lot of places where we make an
>>>> implicit assumption that GF_CALLOC and the likes memset the memory area
>>>> to zero.
>>>>
>>>
>>> Actually I was a bit disturbed recently when I found that at least one
>>> member of that family (don't remember which) *doesn't* do that. I meant
>>> to go through and check which code relied on that unmet assumption, but
>>> then something else came up and I never got back to it.
>>>
>>>
>>>
>> I did a quick scan of mem-pool.c but failed to notice anything obvious.
>> If you
>> happen to notice it again, it should be worth a patch.
>>
>
>
> Mem-pool does zero memory, but none of GF_CALLOC, GF_MALLOC, or GF_REALLOC
> do. For example, GF_CALLOC just calls __gf_calloc which just calls calloc.
>
> 108 req_size = nmemb * size;
> 109 tot_size = req_size + GF_MEM_HEADER_SIZE +
> GF_MEM_TRAILER_SIZE;
> 110
> 111 ptr = calloc (1, tot_size);
>
>
calloc() is doing the zeroing.. no?
Avati
> The only thing after that is gf_mem_set_acct_info, which doesn't (and
> shouldn't) zero memory. Nonetheless, the assumption you refer to is common
> in code which calls these functions. Code which has been converted to use
> mem-pool is safe, but that leaves a lot of code which is still unsafe.
>
>
> ______________________________**_________________
> Gluster-devel mailing list
> Gluster-devel at nongnu.org
> https://lists.nongnu.org/**mailman/listinfo/gluster-devel<https://lists.nongnu.org/mailman/listinfo/gluster-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://supercolony.gluster.org/pipermail/gluster-devel/attachments/20130430/77528ca3/attachment-0001.html>
More information about the Gluster-devel
mailing list