test/danetest.c:337: error: MEMORY_LEAK
  memory dynamically allocated by call to `SSL_dane_enable()` at line 328, column 13 is not reachable after line 337, column 17.
Showing all 81 steps of the trace


test/danetest.c:293:1: start of procedure test_tlsafile()
291.   }
292.   
293. > static int test_tlsafile(SSL_CTX *ctx, const char *base_name,
294.                            BIO *f, const char *path)
295.   {

test/danetest.c:297:5: 
295.   {
296.       char *line;
297. >     int testno = 0;
298.       int ret = 1;
299.       SSL *ssl;

test/danetest.c:298:5: 
296.       char *line;
297.       int testno = 0;
298. >     int ret = 1;
299.       SSL *ssl;
300.   

test/danetest.c:301:12: Loop condition is true. Entering loop body
299.       SSL *ssl;
300.   
301.       while (ret > 0 && (line = read_to_eol(f)) != NULL) {
                  ^
302.           STACK_OF(X509) *chain;
303.           int ntlsa;

test/danetest.c:301:23: Loop condition is true. Entering loop body
299.       SSL *ssl;
300.   
301.       while (ret > 0 && (line = read_to_eol(f)) != NULL) {
                             ^
302.           STACK_OF(X509) *chain;
303.           int ntlsa;

test/danetest.c:314:13: Taking false branch
312.           int mdpth;
313.   
314.           if (*line == '\0' || *line == '#')
                   ^
315.               continue;
316.   

test/danetest.c:314:30: Taking false branch
312.           int mdpth;
313.   
314.           if (*line == '\0' || *line == '#')
                                    ^
315.               continue;
316.   

test/danetest.c:317:9: 
315.               continue;
316.   
317. >         ++testno;
318.           if (sscanf(line, "%d %d %d %d %d%n",
319.                      &ntlsa, &ncert, &noncheck, &want, &want_depth, &off) != 5

test/danetest.c:318:13: Taking false branch
316.   
317.           ++testno;
318.           if (sscanf(line, "%d %d %d %d %d%n",
                   ^
319.                      &ntlsa, &ncert, &noncheck, &want, &want_depth, &off) != 5
320.               || !allws(line + off)) {

test/danetest.c:320:17: Taking false branch
318.           if (sscanf(line, "%d %d %d %d %d%n",
319.                      &ntlsa, &ncert, &noncheck, &want, &want_depth, &off) != 5
320.               || !allws(line + off)) {
                       ^
321.               TEST_error("Malformed line for test %d", testno);
322.               return 0;

test/danetest.c:325:14: Skipping SSL_new(): empty list of specs
323.           }
324.   
325.           if (!TEST_ptr(ssl = SSL_new(ctx)))
                    ^
326.               return 0;
327.           SSL_set_connect_state(ssl);

test/testutil/tests.c:227:1: start of procedure test_ptr()
  225.   }
  226.   
  227. > int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)

test/testutil/tests.c:229:9: Taking true branch
  227.   int test_ptr(const char *file, int line, const char *s, const void *p)
  228.   {
  229.       if (p != NULL)
                 ^
  230.           return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:230:9: 
  228.   {
  229.       if (p != NULL)
  230. >         return 1;
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;

test/testutil/tests.c:233:1: return from a call to test_ptr
  231.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  232.       return 0;
  233. > }
  234.   
  235.   int test_true(const char *file, int line, const char *s, int b)

test/danetest.c:325:14: Taking false branch
323.           }
324.   
325.           if (!TEST_ptr(ssl = SSL_new(ctx)))
                    ^
326.               return 0;
327.           SSL_set_connect_state(ssl);

test/danetest.c:327:9: 
325.           if (!TEST_ptr(ssl = SSL_new(ctx)))
326.               return 0;
327. >         SSL_set_connect_state(ssl);
328.           if (SSL_dane_enable(ssl, base_name) <= 0) {
329.               SSL_free(ssl);

ssl/ssl_lib.c:3383:1: start of procedure SSL_set_connect_state()
  3381.   }
  3382.   
  3383. > void SSL_set_connect_state(SSL *s)
  3384.   {
  3385.       s->server = 0;

ssl/ssl_lib.c:3385:5: 
  3383.   void SSL_set_connect_state(SSL *s)
  3384.   {
  3385. >     s->server = 0;
  3386.       s->shutdown = 0;
  3387.       ossl_statem_clear(s);

ssl/ssl_lib.c:3386:5: 
  3384.   {
  3385.       s->server = 0;
  3386. >     s->shutdown = 0;
  3387.       ossl_statem_clear(s);
  3388.       s->handshake_func = s->method->ssl_connect;

ssl/ssl_lib.c:3387:5: 
  3385.       s->server = 0;
  3386.       s->shutdown = 0;
  3387. >     ossl_statem_clear(s);
  3388.       s->handshake_func = s->method->ssl_connect;
  3389.       clear_ciphers(s);

ssl/statem/statem.c:96:1: start of procedure ossl_statem_clear()
    94.    * Clear the state machine state and reset back to MSG_FLOW_UNINITED
    95.    */
    96. > void ossl_statem_clear(SSL *s)
    97.   {
    98.       s->statem.state = MSG_FLOW_UNINITED;

ssl/statem/statem.c:98:5: 
    96.   void ossl_statem_clear(SSL *s)
    97.   {
    98. >     s->statem.state = MSG_FLOW_UNINITED;
    99.       s->statem.hand_state = TLS_ST_BEFORE;
    100.       s->statem.in_init = 1;

ssl/statem/statem.c:99:5: 
    97.   {
    98.       s->statem.state = MSG_FLOW_UNINITED;
    99. >     s->statem.hand_state = TLS_ST_BEFORE;
    100.       s->statem.in_init = 1;
    101.       s->statem.no_cert_verify = 0;

ssl/statem/statem.c:100:5: 
    98.       s->statem.state = MSG_FLOW_UNINITED;
    99.       s->statem.hand_state = TLS_ST_BEFORE;
    100. >     s->statem.in_init = 1;
    101.       s->statem.no_cert_verify = 0;
    102.   }

ssl/statem/statem.c:101:5: 
    99.       s->statem.hand_state = TLS_ST_BEFORE;
    100.       s->statem.in_init = 1;
    101. >     s->statem.no_cert_verify = 0;
    102.   }
    103.   

ssl/statem/statem.c:102:1: return from a call to ossl_statem_clear
    100.       s->statem.in_init = 1;
    101.       s->statem.no_cert_verify = 0;
    102. > }
    103.   
    104.   /*

ssl/ssl_lib.c:3388:5: 
  3386.       s->shutdown = 0;
  3387.       ossl_statem_clear(s);
  3388. >     s->handshake_func = s->method->ssl_connect;
  3389.       clear_ciphers(s);
  3390.   }

ssl/ssl_lib.c:3389:5: Skipping clear_ciphers(): empty list of specs
  3387.       ossl_statem_clear(s);
  3388.       s->handshake_func = s->method->ssl_connect;
  3389.       clear_ciphers(s);
              ^
  3390.   }
  3391.   

ssl/ssl_lib.c:3390:1: return from a call to SSL_set_connect_state
  3388.       s->handshake_func = s->method->ssl_connect;
  3389.       clear_ciphers(s);
  3390. > }
  3391.   
  3392.   int ssl_undefined_function(SSL *s)

test/danetest.c:328:13: 
326.               return 0;
327.           SSL_set_connect_state(ssl);
328. >         if (SSL_dane_enable(ssl, base_name) <= 0) {
329.               SSL_free(ssl);
330.               return 0;

ssl/ssl_lib.c:932:1: start of procedure SSL_dane_enable()
  930.   }
  931.   
  932. > int SSL_dane_enable(SSL *s, const char *basedomain)
  933.   {
  934.       SSL_DANE *dane = &s->dane;

ssl/ssl_lib.c:934:5: 
  932.   int SSL_dane_enable(SSL *s, const char *basedomain)
  933.   {
  934. >     SSL_DANE *dane = &s->dane;
  935.   
  936.       if (s->ctx->dane.mdmax == 0) {

ssl/ssl_lib.c:936:9: Taking false branch
  934.       SSL_DANE *dane = &s->dane;
  935.   
  936.       if (s->ctx->dane.mdmax == 0) {
                 ^
  937.           SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_CONTEXT_NOT_DANE_ENABLED);
  938.           return 0;

ssl/ssl_lib.c:940:9: Taking false branch
  938.           return 0;
  939.       }
  940.       if (dane->trecs != NULL) {
                 ^
  941.           SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_DANE_ALREADY_ENABLED);
  942.           return 0;

ssl/ssl_lib.c:950:9: Taking false branch
  948.        * invalid input, set the SNI name first.
  949.        */
  950.       if (s->ext.hostname == NULL) {
                 ^
  951.           if (!SSL_set_tlsext_host_name(s, basedomain)) {
  952.               SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN);

ssl/ssl_lib.c:958:10: 
  956.   
  957.       /* Primary RFC6125 reference identifier */
  958. >     if (!X509_VERIFY_PARAM_set1_host(s->param, basedomain, 0)) {
  959.           SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN);
  960.           return -1;

crypto/x509/x509_vpm.c:379:1: start of procedure X509_VERIFY_PARAM_set1_host()
    377.   }
    378.   
    379. > int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,
    380.                                   const char *name, size_t namelen)
    381.   {

crypto/x509/x509_vpm.c:382:5: Skipping int_x509_param_set_hosts(): empty list of specs
    380.                                   const char *name, size_t namelen)
    381.   {
    382.       return int_x509_param_set_hosts(param, SET_HOST, name, namelen);
               ^
    383.   }
    384.   

crypto/x509/x509_vpm.c:383:1: return from a call to X509_VERIFY_PARAM_set1_host
    381.   {
    382.       return int_x509_param_set_hosts(param, SET_HOST, name, namelen);
    383. > }
    384.   
    385.   int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param,

ssl/ssl_lib.c:958:10: Taking false branch
  956.   
  957.       /* Primary RFC6125 reference identifier */
  958.       if (!X509_VERIFY_PARAM_set1_host(s->param, basedomain, 0)) {
                  ^
  959.           SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN);
  960.           return -1;

ssl/ssl_lib.c:963:5: 
  961.       }
  962.   
  963. >     dane->mdpth = -1;
  964.       dane->pdpth = -1;
  965.       dane->dctx = &s->ctx->dane;

ssl/ssl_lib.c:964:5: 
  962.   
  963.       dane->mdpth = -1;
  964. >     dane->pdpth = -1;
  965.       dane->dctx = &s->ctx->dane;
  966.       dane->trecs = sk_danetls_record_new_null();

ssl/ssl_lib.c:965:5: 
  963.       dane->mdpth = -1;
  964.       dane->pdpth = -1;
  965. >     dane->dctx = &s->ctx->dane;
  966.       dane->trecs = sk_danetls_record_new_null();
  967.   

ssl/ssl_lib.c:966:5: 
  964.       dane->pdpth = -1;
  965.       dane->dctx = &s->ctx->dane;
  966. >     dane->trecs = sk_danetls_record_new_null();
  967.   
  968.       if (dane->trecs == NULL) {

include/internal/dane.h:51:1: start of procedure sk_danetls_record_new_null()
    49.   } danetls_record;
    50.   
    51. > DEFINE_STACK_OF(danetls_record)
    52.   
    53.   /*

crypto/stack/stack.c:118:1: start of procedure OPENSSL_sk_new_null()
      116.   }
      117.   
      118. > OPENSSL_STACK *OPENSSL_sk_new_null(void)
      119.   {
      120.       return OPENSSL_zalloc(sizeof(OPENSSL_STACK));

crypto/stack/stack.c:120:5: 
      118.   OPENSSL_STACK *OPENSSL_sk_new_null(void)
      119.   {
      120. >     return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
      121.   }
      122.   

crypto/mem.c:198:1: start of procedure CRYPTO_zalloc()
        196.   }
        197.   
        198. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
        199.   {
        200.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:200:5: 
        198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
        199.   {
        200. >     void *ret = CRYPTO_malloc(num, file, line);
        201.   
        202.       FAILTEST();

crypto/mem.c:170:1: start of procedure CRYPTO_malloc()
          168.   #endif
          169.   
          170. > void *CRYPTO_malloc(size_t num, const char *file, int line)
          171.   {
          172.       void *ret = NULL;

crypto/mem.c:172:5: 
          170.   void *CRYPTO_malloc(size_t num, const char *file, int line)
          171.   {
          172. >     void *ret = NULL;
          173.   
          174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:174:9: Taking false branch
          172.       void *ret = NULL;
          173.   
          174.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                         ^
          175.           return malloc_impl(num, file, line);
          176.   

crypto/mem.c:177:9: Taking false branch
          175.           return malloc_impl(num, file, line);
          176.   
          177.       if (num == 0)
                         ^
          178.           return NULL;
          179.   

crypto/mem.c:181:5: 
          179.   
          180.       FAILTEST();
          181. >     allow_customize = 0;
          182.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
          183.       if (call_malloc_debug) {

crypto/mem.c:191:5: 
          189.       }
          190.   #else
          191. >     (void)(file); (void)(line);
          192.       ret = malloc(num);
          193.   #endif

crypto/mem.c:191:19: 
          189.       }
          190.   #else
          191. >     (void)(file); (void)(line);
          192.       ret = malloc(num);
          193.   #endif

crypto/mem.c:192:5: 
          190.   #else
          191.       (void)(file); (void)(line);
          192. >     ret = malloc(num);
          193.   #endif
          194.   

crypto/mem.c:195:5: 
          193.   #endif
          194.   
          195. >     return ret;
          196.   }
          197.   

crypto/mem.c:196:1: return from a call to CRYPTO_malloc
          194.   
          195.       return ret;
          196. > }
          197.   
          198.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:203:9: Taking true branch
        201.   
        202.       FAILTEST();
        203.       if (ret != NULL)
                       ^
        204.           memset(ret, 0, num);
        205.       return ret;

crypto/mem.c:204:9: 
        202.       FAILTEST();
        203.       if (ret != NULL)
        204. >         memset(ret, 0, num);
        205.       return ret;
        206.   }

crypto/mem.c:205:5: 
        203.       if (ret != NULL)
        204.           memset(ret, 0, num);
        205. >     return ret;
        206.   }
        207.   

crypto/mem.c:206:1: return from a call to CRYPTO_zalloc
        204.           memset(ret, 0, num);
        205.       return ret;
        206. > }
        207.   
        208.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/stack/stack.c:121:1: return from a call to OPENSSL_sk_new_null
      119.   {
      120.       return OPENSSL_zalloc(sizeof(OPENSSL_STACK));
      121. > }
      122.   
      123.   OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc c)

include/internal/dane.h:51:1: return from a call to sk_danetls_record_new_null
    49.   } danetls_record;
    50.   
    51. > DEFINE_STACK_OF(danetls_record)
    52.   
    53.   /*

ssl/ssl_lib.c:968:9: Taking false branch
  966.       dane->trecs = sk_danetls_record_new_null();
  967.   
  968.       if (dane->trecs == NULL) {
                 ^
  969.           SSLerr(SSL_F_SSL_DANE_ENABLE, ERR_R_MALLOC_FAILURE);
  970.           return -1;

ssl/ssl_lib.c:972:5: 
  970.           return -1;
  971.       }
  972. >     return 1;
  973.   }
  974.   

ssl/ssl_lib.c:973:1: return from a call to SSL_dane_enable
  971.       }
  972.       return 1;
  973. > }
  974.   
  975.   unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags)

test/danetest.c:328:13: Taking false branch
326.               return 0;
327.           SSL_set_connect_state(ssl);
328.           if (SSL_dane_enable(ssl, base_name) <= 0) {
                   ^
329.               SSL_free(ssl);
330.               return 0;

test/danetest.c:332:13: Taking true branch
330.               return 0;
331.           }
332.           if (noncheck)
                   ^
333.               SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
334.   

test/danetest.c:333:13: 
331.           }
332.           if (noncheck)
333. >             SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
334.   
335.           for (i = 0; i < ntlsa; ++i) {

ssl/ssl_lib.c:975:1: start of procedure SSL_dane_set_flags()
  973.   }
  974.   
  975. > unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags)
  976.   {
  977.       unsigned long orig = ssl->dane.flags;

ssl/ssl_lib.c:977:5: 
  975.   unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags)
  976.   {
  977. >     unsigned long orig = ssl->dane.flags;
  978.   
  979.       ssl->dane.flags |= flags;

ssl/ssl_lib.c:979:5: 
  977.       unsigned long orig = ssl->dane.flags;
  978.   
  979. >     ssl->dane.flags |= flags;
  980.       return orig;
  981.   }

ssl/ssl_lib.c:980:5: 
  978.   
  979.       ssl->dane.flags |= flags;
  980. >     return orig;
  981.   }
  982.   

ssl/ssl_lib.c:981:1: return from a call to SSL_dane_set_flags
  979.       ssl->dane.flags |= flags;
  980.       return orig;
  981. > }
  982.   
  983.   unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags)

test/danetest.c:335:14: 
333.               SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
334.   
335. >         for (i = 0; i < ntlsa; ++i) {
336.               if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {
337.                   SSL_free(ssl);

test/danetest.c:335:21: Loop condition is true. Entering loop body
333.               SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
334.   
335.           for (i = 0; i < ntlsa; ++i) {
                           ^
336.               if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {
337.                   SSL_free(ssl);

test/danetest.c:336:17: Taking true branch
334.   
335.           for (i = 0; i < ntlsa; ++i) {
336.               if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {
                       ^
337.                   SSL_free(ssl);
338.                   return 0;

test/danetest.c:337:17: Skipping SSL_free(): empty list of specs
335.           for (i = 0; i < ntlsa; ++i) {
336.               if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {
337.                   SSL_free(ssl);
                       ^
338.                   return 0;
339.               }

static int test_tlsafile(SSL_CTX *ctx, const char *base_name,
                         BIO *f, const char *path)
{
    char *line;
    int testno = 0;
    int ret = 1;
    SSL *ssl;
    while (ret > 0 && (line = read_to_eol(f)) != NULL) {
        STACK_OF(X509) *chain;
        int ntlsa;
        int ncert;
        int noncheck;
        int want;
        int want_depth;
        int off;
        int i;
        int ok;
        int err;
        int mdpth;
        if (*line == '\0' || *line == '#')
            continue;
        ++testno;
        if (sscanf(line, "%d %d %d %d %d%n",
                   &ntlsa, &ncert, &noncheck, &want, &want_depth, &off) != 5
            || !allws(line + off)) {
            TEST_error("Malformed line for test %d", testno);
            return 0;
        }
        if (!TEST_ptr(ssl = SSL_new(ctx)))
            return 0;
        SSL_set_connect_state(ssl);
        if (SSL_dane_enable(ssl, base_name) <= 0) {
            SSL_free(ssl);
            return 0;
        }
        if (noncheck)
            SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);
        for (i = 0; i < ntlsa; ++i) {
            if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {
                SSL_free(ssl);
                return 0;
            }
        }
        ERR_clear_error();
        if (!TEST_ptr(chain = load_chain(f, ncert))) {
            SSL_free(ssl);
            return 0;
        }
        ok = verify_chain(ssl, chain);
        sk_X509_pop_free(chain, X509_free);
        err = SSL_get_verify_result(ssl);
        SSL_set_verify_result(ssl, X509_V_OK);
        mdpth = SSL_get0_dane_authority(ssl, NULL, NULL);
        SSL_set_verify_result(ssl, err);
        SSL_free(ssl);
        if (!TEST_int_eq(err, want)) {
            if (want == X509_V_OK)
                TEST_info("Verification failure in test %d: %d=%s",
                          testno, err, X509_verify_cert_error_string(err));
            else
                TEST_info("Unexpected error in test %d", testno);
            ret = 0;
            continue;
        }
        if (!TEST_false(want == 0 && ok == 0)) {
            TEST_info("Verification failure in test %d: ok=0", testno);
            ret = 0;
            continue;
        }
        if (!TEST_int_eq(mdpth, want_depth)) {
            TEST_info("In test test %d", testno);
            ret = 0;
        }
    }
    ERR_clear_error();
    return ret;
}
['static int test_tlsafile(SSL_CTX *ctx, const char *base_name,\n                         BIO *f, const char *path)\n{\n    char *line;\n    int testno = 0;\n    int ret = 1;\n    SSL *ssl;\n    while (ret > 0 && (line = read_to_eol(f)) != NULL) {\n        STACK_OF(X509) *chain;\n        int ntlsa;\n        int ncert;\n        int noncheck;\n        int want;\n        int want_depth;\n        int off;\n        int i;\n        int ok;\n        int err;\n        int mdpth;\n        if (*line == \'\\0\' || *line == \'#\')\n            continue;\n        ++testno;\n        if (sscanf(line, "%d %d %d %d %d%n",\n                   &ntlsa, &ncert, &noncheck, &want, &want_depth, &off) != 5\n            || !allws(line + off)) {\n            TEST_error("Malformed line for test %d", testno);\n            return 0;\n        }\n        if (!TEST_ptr(ssl = SSL_new(ctx)))\n            return 0;\n        SSL_set_connect_state(ssl);\n        if (SSL_dane_enable(ssl, base_name) <= 0) {\n            SSL_free(ssl);\n            return 0;\n        }\n        if (noncheck)\n            SSL_dane_set_flags(ssl, DANE_FLAG_NO_DANE_EE_NAMECHECKS);\n        for (i = 0; i < ntlsa; ++i) {\n            if ((line = read_to_eol(f)) == NULL || !tlsa_import_rr(ssl, line)) {\n                SSL_free(ssl);\n                return 0;\n            }\n        }\n        ERR_clear_error();\n        if (!TEST_ptr(chain = load_chain(f, ncert))) {\n            SSL_free(ssl);\n            return 0;\n        }\n        ok = verify_chain(ssl, chain);\n        sk_X509_pop_free(chain, X509_free);\n        err = SSL_get_verify_result(ssl);\n        SSL_set_verify_result(ssl, X509_V_OK);\n        mdpth = SSL_get0_dane_authority(ssl, NULL, NULL);\n        SSL_set_verify_result(ssl, err);\n        SSL_free(ssl);\n        if (!TEST_int_eq(err, want)) {\n            if (want == X509_V_OK)\n                TEST_info("Verification failure in test %d: %d=%s",\n                          testno, err, X509_verify_cert_error_string(err));\n            else\n                TEST_info("Unexpected error in test %d", testno);\n            ret = 0;\n            continue;\n        }\n        if (!TEST_false(want == 0 && ok == 0)) {\n            TEST_info("Verification failure in test %d: ok=0", testno);\n            ret = 0;\n            continue;\n        }\n        if (!TEST_int_eq(mdpth, want_depth)) {\n            TEST_info("In test test %d", testno);\n            ret = 0;\n        }\n    }\n    ERR_clear_error();\n    return ret;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'void SSL_set_connect_state(SSL *s)\n{\n    s->server = 0;\n    s->shutdown = 0;\n    ossl_statem_clear(s);\n    s->handshake_func = s->method->ssl_connect;\n    clear_ciphers(s);\n}', 'void ossl_statem_clear(SSL *s)\n{\n    s->statem.state = MSG_FLOW_UNINITED;\n    s->statem.hand_state = TLS_ST_BEFORE;\n    s->statem.in_init = 1;\n    s->statem.no_cert_verify = 0;\n}', 'int SSL_dane_enable(SSL *s, const char *basedomain)\n{\n    SSL_DANE *dane = &s->dane;\n    if (s->ctx->dane.mdmax == 0) {\n        SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_CONTEXT_NOT_DANE_ENABLED);\n        return 0;\n    }\n    if (dane->trecs != NULL) {\n        SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_DANE_ALREADY_ENABLED);\n        return 0;\n    }\n    if (s->ext.hostname == NULL) {\n        if (!SSL_set_tlsext_host_name(s, basedomain)) {\n            SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN);\n            return -1;\n        }\n    }\n    if (!X509_VERIFY_PARAM_set1_host(s->param, basedomain, 0)) {\n        SSLerr(SSL_F_SSL_DANE_ENABLE, SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN);\n        return -1;\n    }\n    dane->mdpth = -1;\n    dane->pdpth = -1;\n    dane->dctx = &s->ctx->dane;\n    dane->trecs = sk_danetls_record_new_null();\n    if (dane->trecs == NULL) {\n        SSLerr(SSL_F_SSL_DANE_ENABLE, ERR_R_MALLOC_FAILURE);\n        return -1;\n    }\n    return 1;\n}', 'int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param,\n                                const char *name, size_t namelen)\n{\n    return int_x509_param_set_hosts(param, SET_HOST, name, namelen);\n}', 'DEFINE_STACK_OF(danetls_record)', 'OPENSSL_STACK *OPENSSL_sk_new_null(void)\n{\n    return OPENSSL_zalloc(sizeof(OPENSSL_STACK));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags)\n{\n    unsigned long orig = ssl->dane.flags;\n    ssl->dane.flags |= flags;\n    return orig;\n}']