apps/s_client.c:627: error: USE_AFTER_FREE
  call to `tlsa_import_rr()` eventually accesses memory that was invalidated by call to `free()` on line 627 indirectly during the call to `tlsa_import_rr()`.
Showing all 14 steps of the trace


apps/s_client.c:627:13: invalidation part of the trace starts here
625.       for (i = 0; i < num; ++i) {
626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
627.           if (tlsa_import_rr(con, rrdata) > 0)
                   ^
628.               ++count;
629.       }

apps/s_client.c:627:13: global variable `tlsa_import_rr.data` accessed here
  625.       for (i = 0; i < num; ++i) {
  626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
  627.           if (tlsa_import_rr(con, rrdata) > 0)
                     ^
  628.               ++count;
  629.       }

apps/s_client.c:627:13: when calling `tlsa_import_rr` here
  625.       for (i = 0; i < num; ++i) {
  626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
  627.           if (tlsa_import_rr(con, rrdata) > 0)
                     ^
  628.               ++count;
  629.       }

apps/s_client.c:584:9: global variable `tlsa_import_rr.data` accessed here
    582.           { &selector, "selector", checked_uint8 },
    583.           { &mtype, "mtype", checked_uint8 },
    584.           { &data, "data", hexdecode },
                   ^
    585.           { NULL, }
    586.       };

apps/s_client.c:602:5: when calling `CRYPTO_free` here
    600.       /* The data field is last, so len is its length */
    601.       ret = SSL_dane_tlsa_add(con, usage, selector, mtype, data, len);
    602.       OPENSSL_free(data);
               ^
    603.   
    604.       if (ret == 0) {

crypto/mem.c:233:1: parameter `str` of CRYPTO_free
      231.   }
      232.   
      233. > void CRYPTO_free(void *str)
      234.   {
      235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: was invalidated by call to `free()`
      242.       }
      243.   #else
      244.       free(str);
                 ^
      245.   #endif
      246.   }

apps/s_client.c:627:13: use-after-lifetime part of the trace starts here
625.       for (i = 0; i < num; ++i) {
626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
627.           if (tlsa_import_rr(con, rrdata) > 0)
                   ^
628.               ++count;
629.       }

apps/s_client.c:627:13: global variable `tlsa_import_rr.data` accessed here
  625.       for (i = 0; i < num; ++i) {
  626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
  627.           if (tlsa_import_rr(con, rrdata) > 0)
                     ^
  628.               ++count;
  629.       }

apps/s_client.c:627:13: when calling `tlsa_import_rr` here
  625.       for (i = 0; i < num; ++i) {
  626.           char *rrdata = sk_OPENSSL_STRING_value(rrset, i);
  627.           if (tlsa_import_rr(con, rrdata) > 0)
                     ^
  628.               ++count;
  629.       }

apps/s_client.c:584:9: global variable `tlsa_import_rr.data` accessed here
    582.           { &selector, "selector", checked_uint8 },
    583.           { &mtype, "mtype", checked_uint8 },
    584.           { &data, "data", hexdecode },
                   ^
    585.           { NULL, }
    586.       };

apps/s_client.c:602:5: when calling `CRYPTO_free` here
    600.       /* The data field is last, so len is its length */
    601.       ret = SSL_dane_tlsa_add(con, usage, selector, mtype, data, len);
    602.       OPENSSL_free(data);
               ^
    603.   
    604.       if (ret == 0) {

crypto/mem.c:233:1: parameter `str` of CRYPTO_free
      231.   }
      232.   
      233. > void CRYPTO_free(void *str)
      234.   {
      235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: invalid access occurs here
      242.       }
      243.   #else
      244.       free(str);
                 ^
      245.   #endif
      246.   }

void CRYPTO_free(void *str)
{
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0);
        free(str);
        CRYPTO_mem_debug_free(str, 1);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['static int tlsa_import_rrset(SSL *con, STACK_OF(OPENSSL_STRING) *rrset)\n{\n    int num = sk_OPENSSL_STRING_num(rrset);\n    int count = 0;\n    int i;\n    for (i = 0; i < num; ++i) {\n        char *rrdata = sk_OPENSSL_STRING_value(rrset, i);\n        if (tlsa_import_rr(con, rrdata) > 0)\n            ++count;\n    }\n    return count > 0;\n}', 'static int tlsa_import_rr(SSL *con, const char *rrdata)\n{\n    static uint8_t usage;\n    static uint8_t selector;\n    static uint8_t mtype;\n    static unsigned char *data;\n    static struct tlsa_field tlsa_fields[] = {\n        { &usage, "usage", checked_uint8 },\n        { &selector, "selector", checked_uint8 },\n        { &mtype, "mtype", checked_uint8 },\n        { &data, "data", hexdecode },\n        { NULL, }\n    };\n    struct tlsa_field *f;\n    int ret;\n    const char *cp = rrdata;\n    ossl_ssize_t len = 0;\n    for (f = tlsa_fields; f->var; ++f) {\n        if ((len = f->parser(&cp, f->var)) <= 0) {\n            BIO_printf(bio_err, "%s: warning: bad TLSA %s field in: %s\\n",\n                       prog, f->name, rrdata);\n            return 0;\n        }\n    }\n    ret = SSL_dane_tlsa_add(con, usage, selector, mtype, data, len);\n    OPENSSL_free(data);\n    if (ret == 0) {\n        ERR_print_errors(bio_err);\n        BIO_printf(bio_err, "%s: warning: unusable TLSA rrdata: %s\\n",\n                   prog, rrdata);\n        return 0;\n    }\n    if (ret < 0) {\n        ERR_print_errors(bio_err);\n        BIO_printf(bio_err, "%s: warning: error loading TLSA rrdata: %s\\n",\n                   prog, rrdata);\n        return 0;\n    }\n    return ret;\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']