ssl/statem/statem_clnt.c:3042: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 2986, column 11 is not reachable after line 3042, column 5.
Showing all 67 steps of the trace


ssl/statem/statem_clnt.c:2959:1: start of procedure tls_construct_cke_rsa()
2957.   }
2958.   
2959. > static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt)
2960.   {
2961.   #ifndef OPENSSL_NO_RSA

ssl/statem/statem_clnt.c:2962:5: 
2960.   {
2961.   #ifndef OPENSSL_NO_RSA
2962. >     unsigned char *encdata = NULL;
2963.       EVP_PKEY *pkey = NULL;
2964.       EVP_PKEY_CTX *pctx = NULL;

ssl/statem/statem_clnt.c:2963:5: 
2961.   #ifndef OPENSSL_NO_RSA
2962.       unsigned char *encdata = NULL;
2963. >     EVP_PKEY *pkey = NULL;
2964.       EVP_PKEY_CTX *pctx = NULL;
2965.       size_t enclen;

ssl/statem/statem_clnt.c:2964:5: 
2962.       unsigned char *encdata = NULL;
2963.       EVP_PKEY *pkey = NULL;
2964. >     EVP_PKEY_CTX *pctx = NULL;
2965.       size_t enclen;
2966.       unsigned char *pms = NULL;

ssl/statem/statem_clnt.c:2966:5: 
2964.       EVP_PKEY_CTX *pctx = NULL;
2965.       size_t enclen;
2966. >     unsigned char *pms = NULL;
2967.       size_t pmslen = 0;
2968.   

ssl/statem/statem_clnt.c:2967:5: 
2965.       size_t enclen;
2966.       unsigned char *pms = NULL;
2967. >     size_t pmslen = 0;
2968.   
2969.       if (s->session->peer == NULL) {

ssl/statem/statem_clnt.c:2969:9: Taking false branch
2967.       size_t pmslen = 0;
2968.   
2969.       if (s->session->peer == NULL) {
                ^
2970.           /*
2971.            * We should always have a server certificate with SSL_kRSA.

ssl/statem/statem_clnt.c:2978:5: 
2976.       }
2977.   
2978. >     pkey = X509_get0_pubkey(s->session->peer);
2979.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2980.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,

crypto/x509/x509_cmp.c:264:1: start of procedure X509_get0_pubkey()
  262.   }
  263.   
  264. > EVP_PKEY *X509_get0_pubkey(const X509 *x)
  265.   {
  266.       if (x == NULL)

crypto/x509/x509_cmp.c:266:9: Taking false branch
  264.   EVP_PKEY *X509_get0_pubkey(const X509 *x)
  265.   {
  266.       if (x == NULL)
                 ^
  267.           return NULL;
  268.       return X509_PUBKEY_get0(x->cert_info.key);

crypto/x509/x509_cmp.c:268:5: 
  266.       if (x == NULL)
  267.           return NULL;
  268. >     return X509_PUBKEY_get0(x->cert_info.key);
  269.   }
  270.   

crypto/x509/x_pubkey.c:141:1: start of procedure X509_PUBKEY_get0()
    139.   }
    140.   
    141. > EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    142.   {
    143.       EVP_PKEY *ret = NULL;

crypto/x509/x_pubkey.c:143:5: 
    141.   EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    142.   {
    143. >     EVP_PKEY *ret = NULL;
    144.   
    145.       if (key == NULL || key->public_key == NULL)

crypto/x509/x_pubkey.c:145:9: Taking false branch
    143.       EVP_PKEY *ret = NULL;
    144.   
    145.       if (key == NULL || key->public_key == NULL)
                   ^
    146.           return NULL;
    147.   

crypto/x509/x_pubkey.c:145:24: Taking false branch
    143.       EVP_PKEY *ret = NULL;
    144.   
    145.       if (key == NULL || key->public_key == NULL)
                                  ^
    146.           return NULL;
    147.   

crypto/x509/x_pubkey.c:148:9: Taking true branch
    146.           return NULL;
    147.   
    148.       if (key->pkey != NULL)
                   ^
    149.           return key->pkey;
    150.   

crypto/x509/x_pubkey.c:149:9: 
    147.   
    148.       if (key->pkey != NULL)
    149. >         return key->pkey;
    150.   
    151.       /*

crypto/x509/x_pubkey.c:167:1: return from a call to X509_PUBKEY_get0
    165.   
    166.       return NULL;
    167. > }
    168.   
    169.   EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)

crypto/x509/x509_cmp.c:269:1: return from a call to X509_get0_pubkey
  267.           return NULL;
  268.       return X509_PUBKEY_get0(x->cert_info.key);
  269. > }
  270.   
  271.   EVP_PKEY *X509_get_pubkey(X509 *x)

ssl/statem/statem_clnt.c:2979:9: 
2977.   
2978.       pkey = X509_get0_pubkey(s->session->peer);
2979. >     if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2980.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2981.                    ERR_R_INTERNAL_ERROR);

crypto/evp/p_lib.c:468:1: start of procedure EVP_PKEY_get0_RSA()
  466.   }
  467.   
  468. > RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey)
  469.   {
  470.       if (pkey->type != EVP_PKEY_RSA) {

crypto/evp/p_lib.c:470:9: Taking false branch
  468.   RSA *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey)
  469.   {
  470.       if (pkey->type != EVP_PKEY_RSA) {
                 ^
  471.           EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
  472.           return NULL;

crypto/evp/p_lib.c:474:5: 
  472.           return NULL;
  473.       }
  474. >     return pkey->pkey.rsa;
  475.   }
  476.   

crypto/evp/p_lib.c:475:1: return from a call to EVP_PKEY_get0_RSA
  473.       }
  474.       return pkey->pkey.rsa;
  475. > }
  476.   
  477.   RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)

ssl/statem/statem_clnt.c:2979:9: Taking false branch
2977.   
2978.       pkey = X509_get0_pubkey(s->session->peer);
2979.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
                ^
2980.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2981.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:2985:5: 
2983.       }
2984.   
2985. >     pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2986.       pms = OPENSSL_malloc(pmslen);
2987.       if (pms == NULL) {

ssl/statem/statem_clnt.c:2986:5: 
2984.   
2985.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2986. >     pms = OPENSSL_malloc(pmslen);
2987.       if (pms == NULL) {
2988.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
  190.   #endif
  191.   
  192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194.       void *ret = NULL;

crypto/mem.c:194:5: 
  192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
  193.   {
  194. >     void *ret = NULL;
  195.   
  196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
  195.   
  196.       INCREMENT(malloc_count);
  197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                 ^
  198.           return malloc_impl(num, file, line);
  199.   

crypto/mem.c:200:9: Taking false branch
  198.           return malloc_impl(num, file, line);
  199.   
  200.       if (num == 0)
                 ^
  201.           return NULL;
  202.   

crypto/mem.c:204:9: Taking true branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
  208.            * allocation.
  209.            */
  210. >         allow_customize = 0;
  211.       }
  212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:221:19: 
  219.       }
  220.   #else
  221. >     (void)(file); (void)(line);
  222.       ret = malloc(num);
  223.   #endif

crypto/mem.c:222:5: 
  220.   #else
  221.       (void)(file); (void)(line);
  222. >     ret = malloc(num);
  223.   #endif
  224.   

crypto/mem.c:225:5: 
  223.   #endif
  224.   
  225. >     return ret;
  226.   }
  227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
  224.   
  225.       return ret;
  226. > }
  227.   
  228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

ssl/statem/statem_clnt.c:2987:9: Taking false branch
2985.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2986.       pms = OPENSSL_malloc(pmslen);
2987.       if (pms == NULL) {
                ^
2988.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2989.                    ERR_R_MALLOC_FAILURE);

ssl/statem/statem_clnt.c:2993:5: 
2991.       }
2992.   
2993. >     pms[0] = s->client_version >> 8;
2994.       pms[1] = s->client_version & 0xff;
2995.       /* TODO(size_t): Convert this function */

ssl/statem/statem_clnt.c:2994:5: 
2992.   
2993.       pms[0] = s->client_version >> 8;
2994. >     pms[1] = s->client_version & 0xff;
2995.       /* TODO(size_t): Convert this function */
2996.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {

ssl/statem/statem_clnt.c:2996:9: Taking false branch
2994.       pms[1] = s->client_version & 0xff;
2995.       /* TODO(size_t): Convert this function */
2996.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {
                ^
2997.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2998.                    ERR_R_MALLOC_FAILURE);

ssl/statem/statem_clnt.c:3003:9: Taking true branch
3001.   
3002.       /* Fix buf for TLS and beyond */
3003.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
                ^
3004.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
3005.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:3003:39: 
3001.   
3002.       /* Fix buf for TLS and beyond */
3003. >     if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
3004.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
3005.                    ERR_R_INTERNAL_ERROR);

ssl/packet.c:272:1: start of procedure WPACKET_start_sub_packet_len__()
  270.   }
  271.   
  272. > int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes)
  273.   {
  274.       WPACKET_SUB *sub;

ssl/packet.c:278:10: Condition is false
  276.   
  277.       /* Internal API, so should not fail */
  278.       if (!ossl_assert(pkt->subs != NULL))
                  ^
  279.           return 0;
  280.   

ssl/packet.c:278:10: Taking true branch
  276.   
  277.       /* Internal API, so should not fail */
  278.       if (!ossl_assert(pkt->subs != NULL))
                  ^
  279.           return 0;
  280.   

ssl/packet.c:279:9: 
  277.       /* Internal API, so should not fail */
  278.       if (!ossl_assert(pkt->subs != NULL))
  279. >         return 0;
  280.   
  281.       if ((sub = OPENSSL_zalloc(sizeof(*sub))) == NULL) {

ssl/packet.c:302:1: return from a call to WPACKET_start_sub_packet_len__
  300.   
  301.       return 1;
  302. > }
  303.   
  304.   int WPACKET_start_sub_packet(WPACKET *pkt)

ssl/statem/statem_clnt.c:3003:39: Taking true branch
3001.   
3002.       /* Fix buf for TLS and beyond */
3003.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
                                              ^
3004.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
3005.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:3004:9: 
3002.       /* Fix buf for TLS and beyond */
3003.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
3004. >         SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
3005.                    ERR_R_INTERNAL_ERROR);
3006.           goto err;

test/tls13secretstest.c:194:1: start of procedure ossl_statem_fatal()
  192.   }
  193.   
  194. > void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file,
  195.                              int line)
  196.   {

test/tls13secretstest.c:197:1: return from a call to ossl_statem_fatal
  195.                              int line)
  196.   {
  197. > }
  198.   
  199.   int ossl_statem_export_allowed(SSL *s)

ssl/statem/statem_clnt.c:3041:2: 
3039.   
3040.       return 1;
3041. >  err:
3042.       OPENSSL_clear_free(pms, pmslen);
3043.       EVP_PKEY_CTX_free(pctx);

ssl/statem/statem_clnt.c:3042:5: 
3040.       return 1;
3041.    err:
3042. >     OPENSSL_clear_free(pms, pmslen);
3043.       EVP_PKEY_CTX_free(pctx);
3044.   

crypto/mem.c:316:1: start of procedure CRYPTO_clear_free()
  314.   }
  315.   
  316. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  317.   {
  318.       if (str == NULL)

crypto/mem.c:318:9: Taking false branch
  316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  317.   {
  318.       if (str == NULL)
                 ^
  319.           return;
  320.       if (num)

crypto/mem.c:320:9: Taking true branch
  318.       if (str == NULL)
  319.           return;
  320.       if (num)
                 ^
  321.           OPENSSL_cleanse(str, num);
  322.       CRYPTO_free(str, file, line);

crypto/mem.c:321:9: Skipping OPENSSL_cleanse(): method has no implementation
  319.           return;
  320.       if (num)
  321.           OPENSSL_cleanse(str, num);
                 ^
  322.       CRYPTO_free(str, file, line);
  323.   }

crypto/mem.c:322:5: 
  320.       if (num)
  321.           OPENSSL_cleanse(str, num);
  322. >     CRYPTO_free(str, file, line);
  323.   }

crypto/mem.c:295:1: start of procedure CRYPTO_free()
    293.   }
    294.   
    295. > void CRYPTO_free(void *str, const char *file, int line)
    296.   {
    297.       INCREMENT(free_count);

crypto/mem.c:298:9: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:298:30: Taking true branch
    296.   {
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    299.           free_impl(str, file, line);
    300.           return;

crypto/mem.c:299:9: Skipping __function_pointer__(): unresolved function pointer
    297.       INCREMENT(free_count);
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
                   ^
    300.           return;
    301.       }

crypto/mem.c:300:9: 
    298.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    299.           free_impl(str, file, line);
    300. >         return;
    301.       }
    302.   

crypto/mem.c:314:1: return from a call to CRYPTO_free
    312.       free(str);
    313.   #endif
    314. > }
    315.   
    316.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/mem.c:323:1: return from a call to CRYPTO_clear_free
  321.           OPENSSL_cleanse(str, num);
  322.       CRYPTO_free(str, file, line);
  323. > }
