gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

There are memory leaks in zziplib v0.13.68 which is trigged in zzip_mem_disk_new(in zzip/memdisk.c:78) #40

Closed fantasy7082 closed 6 years ago

fantasy7082 commented 6 years ago

There are some memory leaks in zziplib which is trigged in function zzip_mem_disk_new(in zzip/memdisk.c:78).

Steps to Reproduce:

./unzzip-mem 002-mem-leaks 

=================================================================
==53743==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f0279a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
    #1 0x7ffff6c65261 in zzip_mem_disk_new ../../zzip/memdisk.c:78

Indirect leak of 3808 byte(s) in 28 object(s) allocated from:
    #0 0x7ffff6f0279a in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9879a)
    #1 0x7ffff6c65866 in zzip_mem_entry_new ../../zzip/memdisk.c:197

Indirect leak of 657 byte(s) in 28 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7ffff69214d9 in strndup (/lib/x86_64-linux-gnu/libc.so.6+0x8b4d9)

Indirect leak of 255 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7ffff6c660cb in zzip_mem_entry_new ../../zzip/memdisk.c:251

Indirect leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7ffff6f02602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7ffff6c6252f in zzip_disk_new ../../zzip/mmapped.c:89
    #2 0x7ffff6c67c7f  (/usr/local/zzip-asan/lib/libzzipmmapped-0.so.13+0x7c7f)

Indirect leak of 28 byte(s) in 28 object(s) allocated from:
    #0 0x7ffff6ecc30f in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x6230f)
    #1 0x7ffff6c632d1 in zzip_disk_entry_strdup_comment ../../zzip/mmapped.c:351

SUMMARY: AddressSanitizer: 4836 byte(s) leaked in 87 allocation(s)

POC FILE:https://github.com/fantasy7082/image_test/blob/master/002-mem-leaks-zip

gdraheim commented 6 years ago

I have added an option --with-asan to compile with asan-support, but there is not output from that one.

=> don't know how to reproduce

gdraheim commented 6 years ago

After checking the source code it became apparent that some disk_open() was not partnered with some disk_close() in the bins/*-mem.c parts.

fixed.

gdraheim commented 6 years ago

done.