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


ssl/statem/statem_clnt.c:2778:1: start of procedure tls_construct_cke_rsa()
2776.   }
2777.   
2778. > static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt, int *al)
2779.   {
2780.   #ifndef OPENSSL_NO_RSA

ssl/statem/statem_clnt.c:2781:5: 
2779.   {
2780.   #ifndef OPENSSL_NO_RSA
2781. >     unsigned char *encdata = NULL;
2782.       EVP_PKEY *pkey = NULL;
2783.       EVP_PKEY_CTX *pctx = NULL;

ssl/statem/statem_clnt.c:2782:5: 
2780.   #ifndef OPENSSL_NO_RSA
2781.       unsigned char *encdata = NULL;
2782. >     EVP_PKEY *pkey = NULL;
2783.       EVP_PKEY_CTX *pctx = NULL;
2784.       size_t enclen;

ssl/statem/statem_clnt.c:2783:5: 
2781.       unsigned char *encdata = NULL;
2782.       EVP_PKEY *pkey = NULL;
2783. >     EVP_PKEY_CTX *pctx = NULL;
2784.       size_t enclen;
2785.       unsigned char *pms = NULL;

ssl/statem/statem_clnt.c:2785:5: 
2783.       EVP_PKEY_CTX *pctx = NULL;
2784.       size_t enclen;
2785. >     unsigned char *pms = NULL;
2786.       size_t pmslen = 0;
2787.   

ssl/statem/statem_clnt.c:2786:5: 
2784.       size_t enclen;
2785.       unsigned char *pms = NULL;
2786. >     size_t pmslen = 0;
2787.   
2788.       if (s->session->peer == NULL) {

ssl/statem/statem_clnt.c:2788:9: Taking false branch
2786.       size_t pmslen = 0;
2787.   
2788.       if (s->session->peer == NULL) {
                ^
2789.           /*
2790.            * We should always have a server certificate with SSL_kRSA.

ssl/statem/statem_clnt.c:2796:5: 
2794.       }
2795.   
2796. >     pkey = X509_get0_pubkey(s->session->peer);
2797.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2798.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);

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

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

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

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:270:1: return from a call to X509_get0_pubkey
  268.           return NULL;
  269.       return X509_PUBKEY_get0(x->cert_info.key);
  270. > }
  271.   
  272.   EVP_PKEY *X509_get_pubkey(X509 *x)

ssl/statem/statem_clnt.c:2797:9: 
2795.   
2796.       pkey = X509_get0_pubkey(s->session->peer);
2797. >     if (EVP_PKEY_get0_RSA(pkey) == NULL) {
2798.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2799.           return 0;

crypto/evp/p_lib.c:290:1: start of procedure EVP_PKEY_get0_RSA()
  288.   }
  289.   
  290. > RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  291.   {
  292.       if (pkey->type != EVP_PKEY_RSA) {

crypto/evp/p_lib.c:292:9: Taking false branch
  290.   RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey)
  291.   {
  292.       if (pkey->type != EVP_PKEY_RSA) {
                 ^
  293.           EVPerr(EVP_F_EVP_PKEY_GET0_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
  294.           return NULL;

crypto/evp/p_lib.c:296:5: 
  294.           return NULL;
  295.       }
  296. >     return pkey->pkey.rsa;
  297.   }
  298.   

crypto/evp/p_lib.c:297:1: return from a call to EVP_PKEY_get0_RSA
  295.       }
  296.       return pkey->pkey.rsa;
  297. > }
  298.   
  299.   RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey)

ssl/statem/statem_clnt.c:2797:9: Taking false branch
2795.   
2796.       pkey = X509_get0_pubkey(s->session->peer);
2797.       if (EVP_PKEY_get0_RSA(pkey) == NULL) {
                ^
2798.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_INTERNAL_ERROR);
2799.           return 0;

ssl/statem/statem_clnt.c:2802:5: 
2800.       }
2801.   
2802. >     pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2803.       pms = OPENSSL_malloc(pmslen);
2804.       if (pms == NULL) {

ssl/statem/statem_clnt.c:2803:5: 
2801.   
2802.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2803. >     pms = OPENSSL_malloc(pmslen);
2804.       if (pms == NULL) {
2805.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);

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

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

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

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

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

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

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

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

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

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

ssl/statem/statem_clnt.c:2804:9: Taking false branch
2802.       pmslen = SSL_MAX_MASTER_KEY_LENGTH;
2803.       pms = OPENSSL_malloc(pmslen);
2804.       if (pms == NULL) {
                ^
2805.           SSLerr(SSL_F_TLS_CONSTRUCT_CKE_RSA, ERR_R_MALLOC_FAILURE);
2806.           *al = SSL_AD_INTERNAL_ERROR;

ssl/statem/statem_clnt.c:2810:5: 
2808.       }
2809.   
2810. >     pms[0] = s->client_version >> 8;
2811.       pms[1] = s->client_version & 0xff;
2812.       /* TODO(size_t): Convert this function */

ssl/statem/statem_clnt.c:2811:5: 
2809.   
2810.       pms[0] = s->client_version >> 8;
2811. >     pms[1] = s->client_version & 0xff;
2812.       /* TODO(size_t): Convert this function */
2813.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {

ssl/statem/statem_clnt.c:2813:9: 
2811.       pms[1] = s->client_version & 0xff;
2812.       /* TODO(size_t): Convert this function */
2813. >     if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {
2814.           goto err;
2815.       }

crypto/rand/rand_lib.c:135:1: start of procedure RAND_bytes()
  133.   }
  134.   
  135. > int RAND_bytes(unsigned char *buf, int num)
  136.   {
  137.       const RAND_METHOD *meth = RAND_get_rand_method();

crypto/rand/rand_lib.c:137:5: 
  135.   int RAND_bytes(unsigned char *buf, int num)
  136.   {
  137. >     const RAND_METHOD *meth = RAND_get_rand_method();
  138.       if (meth && meth->bytes)
  139.           return meth->bytes(buf, num);

crypto/rand/rand_lib.c:54:1: start of procedure RAND_get_rand_method()
    52.   }
    53.   
    54. > const RAND_METHOD *RAND_get_rand_method(void)
    55.   {
    56.       const RAND_METHOD *tmp_meth = NULL;

crypto/rand/rand_lib.c:56:5: 
    54.   const RAND_METHOD *RAND_get_rand_method(void)
    55.   {
    56. >     const RAND_METHOD *tmp_meth = NULL;
    57.   
    58.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))

crypto/rand/rand_lib.c:58:10: 
    56.       const RAND_METHOD *tmp_meth = NULL;
    57.   
    58. >     if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
    59.           return NULL;
    60.   

crypto/threads_pthread.c:105:1: start of procedure CRYPTO_THREAD_run_once()
      103.   }
      104.   
      105. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      106.   {
      107.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:107:9: Taking true branch
      105.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
      106.   {
      107.       if (pthread_once(once, init) != 0)
                     ^
      108.           return 0;
      109.   

crypto/threads_pthread.c:108:9: 
      106.   {
      107.       if (pthread_once(once, init) != 0)
      108. >         return 0;
      109.   
      110.       return 1;

crypto/threads_pthread.c:111:1: return from a call to CRYPTO_THREAD_run_once
      109.   
      110.       return 1;
      111. > }
      112.   
      113.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/rand/rand_lib.c:58:10: Condition is false
    56.       const RAND_METHOD *tmp_meth = NULL;
    57.   
    58.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
                   ^
    59.           return NULL;
    60.   

crypto/rand/rand_lib.c:58:10: Taking true branch
    56.       const RAND_METHOD *tmp_meth = NULL;
    57.   
    58.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
                   ^
    59.           return NULL;
    60.   

crypto/rand/rand_lib.c:59:9: 
    57.   
    58.       if (!RUN_ONCE(&rand_lock_init, do_rand_lock_init))
    59. >         return NULL;
    60.   
    61.       CRYPTO_THREAD_write_lock(rand_meth_lock);

crypto/rand/rand_lib.c:81:1: return from a call to RAND_get_rand_method
    79.       CRYPTO_THREAD_unlock(rand_meth_lock);
    80.       return tmp_meth;
    81. > }
    82.   
    83.   #ifndef OPENSSL_NO_ENGINE

crypto/rand/rand_lib.c:138:9: Taking false branch
  136.   {
  137.       const RAND_METHOD *meth = RAND_get_rand_method();
  138.       if (meth && meth->bytes)
                 ^
  139.           return meth->bytes(buf, num);
  140.       RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);

crypto/rand/rand_lib.c:140:5: 
  138.       if (meth && meth->bytes)
  139.           return meth->bytes(buf, num);
  140. >     RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);
  141.       return (-1);
  142.   }

crypto/err/err.c:367:1: start of procedure ERR_put_error()
    365.   /********************************************************/
    366.   
    367. > void ERR_put_error(int lib, int func, int reason, const char *file, int line)
    368.   {
    369.       ERR_STATE *es;

crypto/err/err.c:390:5: 
    388.       }
    389.   #endif
    390. >     es = ERR_get_state();
    391.       if (es == NULL)
    392.           return;

crypto/err/err.c:681:1: start of procedure ERR_get_state()
      679.   }
      680.   
      681. > ERR_STATE *ERR_get_state(void)
      682.   {
      683.       ERR_STATE *state = NULL;

crypto/err/err.c:683:5: 
      681.   ERR_STATE *ERR_get_state(void)
      682.   {
      683. >     ERR_STATE *state = NULL;
      684.   
      685.       if (!RUN_ONCE(&err_init, err_do_init))

crypto/err/err.c:685:10: 
      683.       ERR_STATE *state = NULL;
      684.   
      685. >     if (!RUN_ONCE(&err_init, err_do_init))
      686.           return NULL;
      687.   

crypto/threads_pthread.c:105:1: start of procedure CRYPTO_THREAD_run_once()
        103.   }
        104.   
        105. > int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
        106.   {
        107.       if (pthread_once(once, init) != 0)

crypto/threads_pthread.c:107:9: Taking true branch
        105.   int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
        106.   {
        107.       if (pthread_once(once, init) != 0)
                       ^
        108.           return 0;
        109.   

crypto/threads_pthread.c:108:9: 
        106.   {
        107.       if (pthread_once(once, init) != 0)
        108. >         return 0;
        109.   
        110.       return 1;

crypto/threads_pthread.c:111:1: return from a call to CRYPTO_THREAD_run_once
        109.   
        110.       return 1;
        111. > }
        112.   
        113.   int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))

crypto/err/err.c:685:10: Condition is false
      683.       ERR_STATE *state = NULL;
      684.   
      685.       if (!RUN_ONCE(&err_init, err_do_init))
                      ^
      686.           return NULL;
      687.   

crypto/err/err.c:685:10: Taking true branch
      683.       ERR_STATE *state = NULL;
      684.   
      685.       if (!RUN_ONCE(&err_init, err_do_init))
                      ^
      686.           return NULL;
      687.   

crypto/err/err.c:686:9: 
      684.   
      685.       if (!RUN_ONCE(&err_init, err_do_init))
      686. >         return NULL;
      687.   
      688.       state = CRYPTO_THREAD_get_local(&err_thread_local);

crypto/err/err.c:706:1: return from a call to ERR_get_state
      704.   
      705.       return state;
      706. > }
      707.   
      708.   int ERR_get_next_error_library(void)

crypto/err/err.c:391:9: Taking true branch
    389.   #endif
    390.       es = ERR_get_state();
    391.       if (es == NULL)
                   ^
    392.           return;
    393.   

crypto/err/err.c:392:9: 
    390.       es = ERR_get_state();
    391.       if (es == NULL)
    392. >         return;
    393.   
    394.       es->top = (es->top + 1) % ERR_NUM_ERRORS;

crypto/err/err.c:402:1: return from a call to ERR_put_error
    400.       es->err_line[es->top] = line;
    401.       err_clear_data(es, es->top);
    402. > }
    403.   
    404.   void ERR_clear_error(void)

crypto/rand/rand_lib.c:141:5: 
  139.           return meth->bytes(buf, num);
  140.       RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);
  141. >     return (-1);
  142.   }
  143.   

crypto/rand/rand_lib.c:142:1: return from a call to RAND_bytes
  140.       RANDerr(RAND_F_RAND_BYTES, RAND_R_FUNC_NOT_IMPLEMENTED);
  141.       return (-1);
  142. > }
  143.   
  144.   #if OPENSSL_API_COMPAT < 0x10100000L

ssl/statem/statem_clnt.c:2813:9: Taking true branch
2811.       pms[1] = s->client_version & 0xff;
2812.       /* TODO(size_t): Convert this function */
2813.       if (RAND_bytes(pms + 2, (int)(pmslen - 2)) <= 0) {
                ^
2814.           goto err;
2815.       }

ssl/statem/statem_clnt.c:2850:2: 
2848.   
2849.       return 1;
2850. >  err:
2851.       OPENSSL_clear_free(pms, pmslen);
2852.       EVP_PKEY_CTX_free(pctx);

ssl/statem/statem_clnt.c:2851:5: 
2849.       return 1;
2850.    err:
2851. >     OPENSSL_clear_free(pms, pmslen);
2852.       EVP_PKEY_CTX_free(pctx);
2853.   

crypto/mem.c:284:1: start of procedure CRYPTO_clear_free()
  282.   }
  283.   
  284. > void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  285.   {
  286.       if (str == NULL)

crypto/mem.c:286:9: Taking false branch
  284.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)
  285.   {
  286.       if (str == NULL)
                 ^
  287.           return;
  288.       if (num)

crypto/mem.c:288:9: Taking true branch
  286.       if (str == NULL)
  287.           return;
  288.       if (num)
                 ^
  289.           OPENSSL_cleanse(str, num);
  290.       CRYPTO_free(str, file, line);

crypto/mem.c:289:9: Skipping OPENSSL_cleanse(): method has no implementation
  287.           return;
  288.       if (num)
  289.           OPENSSL_cleanse(str, num);
                 ^
  290.       CRYPTO_free(str, file, line);
  291.   }

crypto/mem.c:290:5: 
  288.       if (num)
  289.           OPENSSL_cleanse(str, num);
  290. >     CRYPTO_free(str, file, line);
  291.   }

crypto/mem.c:264:1: start of procedure CRYPTO_free()
    262.   }
    263.   
    264. > void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:266:9: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:266:30: Taking true branch
    264.   void CRYPTO_free(void *str, const char *file, int line)
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    267.           free_impl(str, file, line);
    268.           return;

crypto/mem.c:267:9: Skipping __function_pointer__(): unresolved function pointer
    265.   {
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
                   ^
    268.           return;
    269.       }

crypto/mem.c:268:9: 
    266.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    267.           free_impl(str, file, line);
    268. >         return;
    269.       }
    270.   

crypto/mem.c:282:1: return from a call to CRYPTO_free
    280.       free(str);
    281.   #endif
    282. > }
    283.   
    284.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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