[Gluster-devel] Unchecked malloc

Emmanuel Dreyfus manu at netbsd.org
Thu Feb 13 01:13:56 UTC 2014


I have hit another unchecked malloc bug in 3.5.0beta3:

                ptr = GF_CALLOC (1, mem_pool->padded_sizeof_type,
                /* Memory coming from the heap need not be transformed from a
                 * chunkhead to a usable pointer since it is not coming from
                 * the pool. 
        pool_ptr = mem_pool_from_ptr (ptr);
        *pool_ptr = (struct mem_pool *)mem_pool; 

And here it crashes because pool_ptr was derived from ptr, which is NULL.

I submitted a change for this (http://review.gluster.org/6796), which was
reviewed -1, and indeed it is not good enough because:
1) it is incomplete, as unchecked mallocs are now very common in glusterfs
code, and 
2) as I do not know enough about glusterfs internals, I cannot propose
appropriate outcomes for various failures. Clearly someone else more
knowledgable than me has to handle it.

Emmanuel Dreyfus
manu at netbsd.org

More information about the Gluster-devel mailing list