crypto/cms/cms_pwri.c:226: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 191, column 16 is not reachable after line 226, column 5.
Showing all 68 steps of the trace


crypto/cms/cms_pwri.c:176:1: start of procedure kek_unwrap_key()
174.    */
175.   
176. > static int kek_unwrap_key(unsigned char *out, size_t *outlen,
177.                             const unsigned char *in, size_t inlen,
178.                             EVP_CIPHER_CTX *ctx)

crypto/cms/cms_pwri.c:180:5: 
178.                             EVP_CIPHER_CTX *ctx)
179.   {
180. >     size_t blocklen = EVP_CIPHER_CTX_block_size(ctx);
181.       unsigned char *tmp;
182.       int outl, rv = 0;

crypto/evp/evp_lib.c:221:1: start of procedure EVP_CIPHER_CTX_block_size()
  219.   }
  220.   
  221. > int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
  222.   {
  223.       return EVP_CIPHER_block_size(ctx->cipher);

crypto/evp/evp_lib.c:223:5: 
  221.   int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
  222.   {
  223. >     return EVP_CIPHER_block_size(ctx->cipher);
  224.   }
  225.   

crypto/evp/evp_lib.c:210:1: start of procedure EVP_CIPHER_block_size()
    208.   }
    209.   
    210. > int EVP_CIPHER_block_size(const EVP_CIPHER *cipher)
    211.   {
    212.       if (cipher->prov != NULL) {

crypto/evp/evp_lib.c:212:9: Taking true branch
    210.   int EVP_CIPHER_block_size(const EVP_CIPHER *cipher)
    211.   {
    212.       if (cipher->prov != NULL) {
                   ^
    213.           if (cipher->blocksize != NULL)
    214.               return cipher->blocksize();

crypto/evp/evp_lib.c:213:13: Taking true branch
    211.   {
    212.       if (cipher->prov != NULL) {
    213.           if (cipher->blocksize != NULL)
                       ^
    214.               return cipher->blocksize();
    215.           /* We default to a block size of 1 */

crypto/evp/evp_lib.c:214:13: Skipping __function_pointer__(): unresolved function pointer
    212.       if (cipher->prov != NULL) {
    213.           if (cipher->blocksize != NULL)
    214.               return cipher->blocksize();
                       ^
    215.           /* We default to a block size of 1 */
    216.           return 1;

crypto/evp/evp_lib.c:219:1: return from a call to EVP_CIPHER_block_size
    217.       }
    218.       return cipher->block_size;
    219. > }
    220.   
    221.   int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)

crypto/evp/evp_lib.c:224:1: return from a call to EVP_CIPHER_CTX_block_size
  222.   {
  223.       return EVP_CIPHER_block_size(ctx->cipher);
  224. > }
  225.   
  226.   int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *e)

crypto/cms/cms_pwri.c:182:5: 
180.       size_t blocklen = EVP_CIPHER_CTX_block_size(ctx);
181.       unsigned char *tmp;
182. >     int outl, rv = 0;
183.       if (inlen < 2 * blocklen) {
184.           /* too small */

crypto/cms/cms_pwri.c:183:9: Taking false branch
181.       unsigned char *tmp;
182.       int outl, rv = 0;
183.       if (inlen < 2 * blocklen) {
               ^
184.           /* too small */
185.           return 0;

crypto/cms/cms_pwri.c:187:9: Taking false branch
185.           return 0;
186.       }
187.       if (inlen % blocklen) {
               ^
188.           /* Invalid size */
189.           return 0;

crypto/cms/cms_pwri.c:191:9: 
189.           return 0;
190.       }
191. >     if ((tmp = OPENSSL_malloc(inlen)) == NULL) {
192.           CMSerr(CMS_F_KEK_UNWRAP_KEY, ERR_R_MALLOC_FAILURE);
193.           return 0;

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)

crypto/cms/cms_pwri.c:191:9: Taking false branch
189.           return 0;
190.       }
191.       if ((tmp = OPENSSL_malloc(inlen)) == NULL) {
               ^
192.           CMSerr(CMS_F_KEK_UNWRAP_KEY, ERR_R_MALLOC_FAILURE);
193.           return 0;

crypto/cms/cms_pwri.c:196:10: 
194.       }
195.       /* setup IV by decrypting last two blocks */
196. >     if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl,
197.                              in + inlen - 2 * blocklen, blocklen * 2)
198.           /*

crypto/evp/evp_enc.c:695:1: start of procedure EVP_DecryptUpdate()
  693.   }
  694.   
  695. > int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
  696.                         const unsigned char *in, int inl)
  697.   {

crypto/evp/evp_enc.c:698:5: 
  696.                         const unsigned char *in, int inl)
  697.   {
  698. >     int fix_len, cmpl = inl, ret;
  699.       unsigned int b;
  700.       size_t soutl;

crypto/evp/evp_enc.c:704:9: Taking false branch
  702.   
  703.       /* Prevent accidental use of encryption context when decrypting */
  704.       if (ctx->encrypt) {
                 ^
  705.           EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_INVALID_OPERATION);
  706.           return 0;

crypto/evp/evp_enc.c:709:9: Taking false branch
  707.       }
  708.   
  709.       if (ctx->cipher == NULL) {
                 ^
  710.           EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_NO_CIPHER_SET);
  711.           return 0;

crypto/evp/evp_enc.c:713:9: Taking false branch
  711.           return 0;
  712.       }
  713.       if (ctx->cipher->prov == NULL)
                 ^
  714.           goto legacy;
  715.   

crypto/evp/evp_enc.c:716:5: 
  714.           goto legacy;
  715.   
  716. >     blocksize = EVP_CIPHER_CTX_block_size(ctx);
  717.   
  718.       if (ctx->cipher->cupdate == NULL || blocksize < 1) {

crypto/evp/evp_lib.c:221:1: start of procedure EVP_CIPHER_CTX_block_size()
    219.   }
    220.   
    221. > int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
    222.   {
    223.       return EVP_CIPHER_block_size(ctx->cipher);

crypto/evp/evp_lib.c:223:5: 
    221.   int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)
    222.   {
    223. >     return EVP_CIPHER_block_size(ctx->cipher);
    224.   }
    225.   

crypto/evp/evp_lib.c:210:1: start of procedure EVP_CIPHER_block_size()
      208.   }
      209.   
      210. > int EVP_CIPHER_block_size(const EVP_CIPHER *cipher)
      211.   {
      212.       if (cipher->prov != NULL) {

crypto/evp/evp_lib.c:212:9: Taking true branch
      210.   int EVP_CIPHER_block_size(const EVP_CIPHER *cipher)
      211.   {
      212.       if (cipher->prov != NULL) {
                     ^
      213.           if (cipher->blocksize != NULL)
      214.               return cipher->blocksize();

crypto/evp/evp_lib.c:213:13: Taking true branch
      211.   {
      212.       if (cipher->prov != NULL) {
      213.           if (cipher->blocksize != NULL)
                         ^
      214.               return cipher->blocksize();
      215.           /* We default to a block size of 1 */

crypto/evp/evp_lib.c:214:13: Skipping __function_pointer__(): unresolved function pointer
      212.       if (cipher->prov != NULL) {
      213.           if (cipher->blocksize != NULL)
      214.               return cipher->blocksize();
                         ^
      215.           /* We default to a block size of 1 */
      216.           return 1;

crypto/evp/evp_lib.c:219:1: return from a call to EVP_CIPHER_block_size
      217.       }
      218.       return cipher->block_size;
      219. > }
      220.   
      221.   int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx)

crypto/evp/evp_lib.c:224:1: return from a call to EVP_CIPHER_CTX_block_size
    222.   {
    223.       return EVP_CIPHER_block_size(ctx->cipher);
    224. > }
    225.   
    226.   int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *e)

crypto/evp/evp_enc.c:718:9: Taking false branch
  716.       blocksize = EVP_CIPHER_CTX_block_size(ctx);
  717.   
  718.       if (ctx->cipher->cupdate == NULL || blocksize < 1) {
                 ^
  719.           EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);
  720.           return 0;

crypto/evp/evp_enc.c:718:41: Taking false branch
  716.       blocksize = EVP_CIPHER_CTX_block_size(ctx);
  717.   
  718.       if (ctx->cipher->cupdate == NULL || blocksize < 1) {
                                                 ^
  719.           EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);
  720.           return 0;

crypto/evp/evp_enc.c:723:39: Condition is true
  721.       }
  722.       ret = ctx->cipher->cupdate(ctx->provctx, out, &soutl,
  723.                                  inl + (blocksize == 1 ? 0 : blocksize), in,
                                               ^
  724.                                  (size_t)inl);
  725.   

crypto/evp/evp_enc.c:722:5: Skipping __function_pointer__(): unresolved function pointer
  720.           return 0;
  721.       }
  722.       ret = ctx->cipher->cupdate(ctx->provctx, out, &soutl,
             ^
  723.                                  inl + (blocksize == 1 ? 0 : blocksize), in,
  724.                                  (size_t)inl);

crypto/evp/evp_enc.c:726:9: Taking true branch
  724.                                  (size_t)inl);
  725.   
  726.       if (ret) {
                 ^
  727.           if (soutl > INT_MAX) {
  728.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);

crypto/evp/evp_enc.c:727:13: Taking true branch
  725.   
  726.       if (ret) {
  727.           if (soutl > INT_MAX) {
                     ^
  728.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);
  729.               return 0;

crypto/evp/evp_enc.c:728:13: Skipping ERR_put_error(): empty list of specs
  726.       if (ret) {
  727.           if (soutl > INT_MAX) {
  728.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);
                     ^
  729.               return 0;
  730.           }

crypto/evp/evp_enc.c:729:13: 
  727.           if (soutl > INT_MAX) {
  728.               EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_UPDATE_ERROR);
  729. >             return 0;
  730.           }
  731.           *outl = soutl;

crypto/evp/evp_enc.c:800:1: return from a call to EVP_DecryptUpdate
  798.   
  799.       return 1;
  800. > }
  801.   
  802.   int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)

crypto/cms/cms_pwri.c:196:10: Taking true branch
194.       }
195.       /* setup IV by decrypting last two blocks */
196.       if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl,
                ^
197.                              in + inlen - 2 * blocklen, blocklen * 2)
198.           /*

crypto/cms/cms_pwri.c:225:2: 
223.       memcpy(out, tmp + 4, *outlen);
224.       rv = 1;
225. >  err:
226.       OPENSSL_clear_free(tmp, inlen);
227.       return rv;

crypto/cms/cms_pwri.c:226:5: 
224.       rv = 1;
225.    err:
226. >     OPENSSL_clear_free(tmp, inlen);
227.       return rv;
228.   

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: 
  319.           return;
  320.       if (num)
  321. >         OPENSSL_cleanse(str, num);
  322.       CRYPTO_free(str, file, line);
  323.   }

crypto/mem_clr.c:22:1: start of procedure OPENSSL_cleanse()
    20.   static volatile memset_t memset_func = memset;
    21.   
    22. > void OPENSSL_cleanse(void *ptr, size_t len)
    23.   {
    24.       memset_func(ptr, 0, len);

crypto/mem_clr.c:24:5: Skipping __function_pointer__(): unresolved function pointer
    22.   void OPENSSL_cleanse(void *ptr, size_t len)
    23.   {
    24.       memset_func(ptr, 0, len);
              ^
    25.   }

crypto/mem_clr.c:25:1: return from a call to OPENSSL_cleanse
    23.   {
    24.       memset_func(ptr, 0, len);
    25. > }

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