Skip to content

Memory leak(s) in parser2tree_fuzzer()

==21937==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 152 byte(s) in 1 object(s) allocated from:
    #0 0x4c8a0a in calloc (/home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer+0x4c8a0a)
    #1 0x50507f in _asn1_add_static_node /home/oms/src/libtasn1/lib/parser_aux.c:71:10
    #2 0x4fcb01 in _asn1_yyparse /home/oms/src/libtasn1/lib/ASN1.y:194:19
    #3 0x503dcb in asn1_parser2tree /home/oms/src/libtasn1/lib/ASN1.y:676:3
    #4 0x4f7bb9 in LLVMFuzzerTestOneInput /home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer.c:59:11
    #5 0x569923 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer+0x569923)

Indirect leak of 26 byte(s) in 1 object(s) allocated from:
    #0 0x4c8813 in __interceptor_malloc (/home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer+0x4c8813)
    #1 0x50696d in _asn1_set_value /home/oms/src/libtasn1/lib/parser_aux.c:273:21
    #2 0x4fcbb1 in _asn1_yyparse /home/oms/src/libtasn1/lib/ASN1.y
    #3 0x503dcb in asn1_parser2tree /home/oms/src/libtasn1/lib/ASN1.y:676:3
    #4 0x4f7bb9 in LLVMFuzzerTestOneInput /home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer.c:59:11
    #5 0x569923 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/oms/src/libtasn1/fuzz/libtasn1_parser2tree_fuzzer+0x569923)

Corpus attached (rename it to 'pkix.asn'), code to reproduce is

	char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
	asn1_node definitions = NULL;

	int rc = asn1_parser2tree("pkix.asn", &definitions, errorDescription);
	if (rc == ASN1_SUCCESS) {
		asn1_delete_structure(&definitions);
	}

leak-9bc24fece80607d1e4b7177d2f6172ea4c17e4c8

Edited by Tim Rühsen