stcorp / coda

The Common Data Access toolset
http://stcorp.github.io/coda/doc/html/index.html
BSD 3-Clause "New" or "Revised" License
37 stars 17 forks source link

coda_recognize_file_fuzzer: Direct-leak in coda_mem_record_new #59

Closed schwehr closed 4 years ago

schwehr commented 4 years ago
==231736==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #1 0x55f342eba1a5 in coda_mem_record_new third_party/stcorp_coda/libcoda/coda-mem-type.c:438:31
    #2 0x55f342e91d55 in read_grib1_message third_party/stcorp_coda/libcoda/coda-grib.c:1712:19
    #3 0x55f342e84eb2 in coda_grib_reopen third_party/stcorp_coda/libcoda/coda-grib.c:3105:17
    #4 0x55f342ec76db in reopen_with_backend third_party/stcorp_coda/libcoda/coda-product.c:410:17
    #5 0x55f342ec44c8 in open_file third_party/stcorp_coda/libcoda/coda-product.c:552:9
    #6 0x55f342ec3e0a in coda_recognize_file third_party/stcorp_coda/libcoda/coda-product.c:596:9
    #7 0x55f342dd9c91 in LLVMFuzzerTestOneInput third_party/stcorp_coda/fuzz/coda_recognize_file_fuzzer.cc:19:3

Indirect leak of 256 byte(s) in 1 object(s) allocated from:
    #1 0x55f342f2266c in coda_hashtable_insert_name third_party/stcorp_coda/libcoda/hashtable.c:166:32
    #2 0x55f342f0eec4 in coda_type_record_insert_field third_party/stcorp_coda/libcoda/coda-type.c:1331:9
    #3 0x55f342f0df17 in coda_type_record_add_field third_party/stcorp_coda/libcoda/coda-type.c:1427:12
    #4 0x55f342e88a30 in grib_init third_party/stcorp_coda/libcoda/coda-grib.c:658:5
    #5 0x55f342e84642 in coda_grib_reopen third_party/stcorp_coda/libcoda/coda-grib.c:3010:9
    #6 0x55f342ec76db in reopen_with_backend third_party/stcorp_coda/libcoda/coda-product.c:410:17
    #7 0x55f342ec44c8 in open_file third_party/stcorp_coda/libcoda/coda-product.c:552:9
    #8 0x55f342ec3e0a in coda_recognize_file third_party/stcorp_coda/libcoda/coda-product.c:596:9
    #9 0x55f342dd9c91 in LLVMFuzzerTestOneInput third_party/stcorp_coda/fuzz/coda_recognize_file_fuzzer.cc:19:3

There were a lot more indirect leaks.

testcase-5060985932480512.zip

svniemeijer commented 4 years ago

Your merge request does seem to solve the leak with the testcase as far as I can see. So please either close this issue or detail what leak you are still seeing.

schwehr commented 4 years ago

It looks like it does indeed fix the issue

schwehr commented 4 years ago

Verified