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


ssl/statem/statem_clnt.c:2891:1: start of procedure tls_construct_cke_rsa()
2889.   }
2890.   
2891. > static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt)
2892.   {
2893.   #ifndef OPENSSL_NO_RSA

ssl/statem/statem_clnt.c:2894:5: 
2892.   {
2893.   #ifndef OPENSSL_NO_RSA
2894. >     unsigned char *encdata = NULL;
2895.       EVP_PKEY *pkey = NULL;
2896.       EVP_PKEY_CTX *pctx = NULL;

ssl/statem/statem_clnt.c:2895:5: 
2893.   #ifndef OPENSSL_NO_RSA
2894.       unsigned char *encdata = NULL;
2895. >     EVP_PKEY *pkey = NULL;
2896.       EVP_PKEY_CTX *pctx = NULL;
2897.       size_t enclen;

ssl/statem/statem_clnt.c:2896:5: 
2894.       unsigned char *encdata = NULL;
2895.       EVP_PKEY *pkey = NULL;
2896. >     EVP_PKEY_CTX *pctx = NULL;
2897.       size_t enclen;
2898.       unsigned char *pms = NULL;

ssl/statem/statem_clnt.c:2898:5: 
2896.       EVP_PKEY_CTX *pctx = NULL;
2897.       size_t enclen;
2898. >     unsigned char *pms = NULL;
2899.       size_t pmslen = 0;
2900.   

ssl/statem/statem_clnt.c:2899:5: 
2897.       size_t enclen;
2898.       unsigned char *pms = NULL;
2899. >     size_t pmslen = 0;
2900.   
2901.       if (s->session->peer == NULL) {

ssl/statem/statem_clnt.c:2901:9: Taking false branch
2899.       size_t pmslen = 0;
2900.   
2901.       if (s->session->peer == NULL) {
                ^
2902.           /*
2903.            * We should always have a server certificate with SSL_kRSA.

ssl/statem/statem_clnt.c:2910:5: 
2908.       }
2909.   
2910. >     pkey = X509_get0_pubkey(s->session->peer);
2911.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2912.           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:140:1: start of procedure X509_PUBKEY_get0()
    138.   }
    139.   
    140. > EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key)
    141.   {
    142.       EVP_PKEY *ret = NULL;

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

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

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

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

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

crypto/x509/x_pubkey.c:166:1: return from a call to X509_PUBKEY_get0
    164.   
    165.       return NULL;
    166. > }
    167.   
    168.   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:2911:9: 
2909.   
2910.       pkey = X509_get0_pubkey(s->session->peer);
2911. >     if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2912.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2913.                    ERR_R_INTERNAL_ERROR);

crypto/evp/p_lib.c:407:1: start of procedure EVP_PKEY_get0_RSA()
  405.   }
  406.   
  407. > RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  408.   {
  409.       if (pkey->type != EVP_PKEY_RSA) {

crypto/evp/p_lib.c:409:9: Taking false branch
  407.   RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  408.   {
  409.       if (pkey->type != EVP_PKEY_RSA) {
                 ^
  410.           EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
  411.           return NULL;

crypto/evp/p_lib.c:413:5: 
  411.           return NULL;
  412.       }
  413. >     return pkey->pkey.rsa;
  414.   }
  415.   

crypto/evp/p_lib.c:414:1: return from a call to EVP_PKEY_get0_RSA
  412.       }
  413.       return pkey->pkey.rsa;
  414. > }
  415.   
  416.   RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)

ssl/statem/statem_clnt.c:2911:9: Taking false branch
2909.   
2910.       pkey = X509_get0_pubkey(s->session->peer);
2911.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
                ^
2912.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2913.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:2917:5: 
2915.       }
2916.   
2917. >     pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2918.       pms = OPENSSL_malloc(pmslen);
2919.       if (pms == NULL) {

ssl/statem/statem_clnt.c:2918:5: 
2916.   
2917.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2918. >     pms = OPENSSL_malloc(pmslen);
2919.       if (pms == NULL) {
2920.           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.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

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:2919:9: Taking false branch
2917.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2918.       pms = OPENSSL_malloc(pmslen);
2919.       if (pms == NULL) {
                ^
2920.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2921.                    ERR_R_MALLOC_FAILURE);

ssl/statem/statem_clnt.c:2925:5: 
2923.       }
2924.   
2925. >     pms[0] = s->client_version >> 8;
2926.       pms[1] = s->client_version & 0xff;
2927.       /* TODO(size_t): Convert this function */

ssl/statem/statem_clnt.c:2926:5: 
2924.   
2925.       pms[0] = s->client_version >> 8;
2926. >     pms[1] = s->client_version & 0xff;
2927.       /* TODO(size_t): Convert this function */
2928.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {

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

ssl/statem/statem_clnt.c:2935:9: Taking true branch
2933.   
2934.       /* Fix buf for TLS and beyond */
2935.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
                ^
2936.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2937.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:2935:39: 
2933.   
2934.       /* Fix buf for TLS and beyond */
2935. >     if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
2936.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2937.                    ERR_R_INTERNAL_ERROR);

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

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

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

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

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

ssl/statem/statem_clnt.c:2935:39: Taking true branch
2933.   
2934.       /* Fix buf for TLS and beyond */
2935.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
                                              ^
2936.           SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2937.                    ERR_R_INTERNAL_ERROR);

ssl/statem/statem_clnt.c:2936:9: 
2934.       /* Fix buf for TLS and beyond */
2935.       if (s->version > SSL3_VERSION && !WPACKET_start_sub_packet_u16(pkt)) {
2936. >         SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
2937.                    ERR_R_INTERNAL_ERROR);
2938.           goto err;

test/tls13secretstest.c:210:1: start of procedure ossl_statem_fatal()
  208.   }
  209.   
  210. > void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file,
  211.                              int line)
  212.   {

test/tls13secretstest.c:213:1: return from a call to ossl_statem_fatal
  211.                              int line)
  212.   {
  213. > }
  214.   
  215.   int ossl_statem_export_allowed(SSL *s)

ssl/statem/statem_clnt.c:2973:2: 
2971.   
2972.       return 1;
2973. >  err:
2974.       OPENSSL_clear_free(pms, pmslen);
2975.       EVP_PKEY_CTX_free(pctx);

ssl/statem/statem_clnt.c:2974:5: 
2972.       return 1;
2973.    err:
2974. >     OPENSSL_clear_free(pms, pmslen);
2975.       EVP_PKEY_CTX_free(pctx);
2976.   

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. > }
