• Yossi Gottlieb's avatar
    Fix wrong zmalloc_size() assumption. (#7963) · 9824fe3e
    Yossi Gottlieb authored
    When using a system with no malloc_usable_size(), zmalloc_size() assumed
    that the heap allocator always returns blocks that are long-padded.
    
    This may not always be the case, and will result with zmalloc_size()
    returning a size that is bigger than allocated. At least in one case
    this leads to out of bound write, process crash and a potential security
    vulnerability.
    
    Effectively this does not affect the vast majority of users, who use
    jemalloc or glibc.
    
    This problem along with a (different) fix was reported by Drew DeVault.
    9824fe3e
zmalloc.c 18.4 KB