crypto/rsa/rsa_oaep.c:280: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 248, column 21 is not reachable after line 280, column 5.
Showing all 54 steps of the trace


crypto/rsa/rsa_oaep.c:243:1: start of procedure PKCS1_MGF1()
241.   }
242.   
243. > int PKCS1_MGF1(unsigned char *mask, long len,
244.                  const unsigned char *seed, long seedlen, const EVP_MD *dgst)
245.   {

crypto/rsa/rsa_oaep.c:246:5: 
244.                  const unsigned char *seed, long seedlen, const EVP_MD *dgst)
245.   {
246. >     long i, outlen = 0;
247.       unsigned char cnt[4];
248.       EVP_MD_CTX *c = EVP_MD_CTX_new();

crypto/rsa/rsa_oaep.c:248:5: 
246.       long i, outlen = 0;
247.       unsigned char cnt[4];
248. >     EVP_MD_CTX *c = EVP_MD_CTX_new();
249.       unsigned char md[EVP_MAX_MD_SIZE];
250.       int mdlen;

crypto/evp/digest.c:44:1: start of procedure EVP_MD_CTX_new()
  42.   }
  43.   
  44. > EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));

crypto/evp/digest.c:46:5: 
  44.   EVP_MD_CTX *EVP_MD_CTX_new(void)
  45.   {
  46. >     return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47.   }
  48.   

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
    96.   }
    97.   
    98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    99.   {
    100. >     void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
      69.   }
      70.   
      71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73.       void *ret = NULL;

crypto/mem.c:73:5: 
      71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      72.   {
      73. >     void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
      73.       void *ret = NULL;
      74.   
      75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                    ^
      76.           return malloc_impl(num, file, line);
      77.   

crypto/mem.c:78:9: Taking false branch
      76.           return malloc_impl(num, file, line);
      77.   
      78.       if (num <= 0)
                    ^
      79.           return NULL;
      80.   

crypto/mem.c:81:5: 
      79.           return NULL;
      80.   
      81. >     allow_customize = 0;
      82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:91:24: 
      89.       }
      90.   #else
      91. >     osslargused(file); osslargused(line);
      92.       ret = malloc(num);
      93.   #endif

crypto/mem.c:92:5: 
      90.   #else
      91.       osslargused(file); osslargused(line);
      92. >     ret = malloc(num);
      93.   #endif
      94.   

crypto/mem.c:95:5: 
      93.   #endif
      94.   
      95. >     return ret;
      96.   }
      97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
      94.   
      95.       return ret;
      96. > }
      97.   
      98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
    100.       void *ret = CRYPTO_malloc(num, file, line);
    101.   
    102.       if (ret != NULL)
                   ^
    103.           memset(ret, 0, num);
    104.       return ret;

crypto/mem.c:103:9: 
    101.   
    102.       if (ret != NULL)
    103. >         memset(ret, 0, num);
    104.       return ret;
    105.   }

crypto/mem.c:104:5: 
    102.       if (ret != NULL)
    103.           memset(ret, 0, num);
    104. >     return ret;
    105.   }
    106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
    103.           memset(ret, 0, num);
    104.       return ret;
    105. > }
    106.   
    107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:47:1: return from a call to EVP_MD_CTX_new
  45.   {
  46.       return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
  47. > }
  48.   
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)

crypto/rsa/rsa_oaep.c:251:5: 
249.       unsigned char md[EVP_MAX_MD_SIZE];
250.       int mdlen;
251. >     int rv = -1;
252.   
253.       if (c == NULL)

crypto/rsa/rsa_oaep.c:253:9: Taking false branch
251.       int rv = -1;
252.   
253.       if (c == NULL)
               ^
254.           goto err;
255.       mdlen = EVP_MD_size(dgst);

crypto/rsa/rsa_oaep.c:255:5: 
253.       if (c == NULL)
254.           goto err;
255. >     mdlen = EVP_MD_size(dgst);
256.       if (mdlen < 0)
257.           goto err;

crypto/evp/evp_lib.c:301:1: start of procedure EVP_MD_size()
  299.   }
  300.   
  301. > int EVP_MD_size(const EVP_MD *md)
  302.   {
  303.       if (!md) {

crypto/evp/evp_lib.c:303:10: Taking false branch
  301.   int EVP_MD_size(const EVP_MD *md)
  302.   {
  303.       if (!md) {
                  ^
  304.           EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
  305.           return -1;

crypto/evp/evp_lib.c:307:5: 
  305.           return -1;
  306.       }
  307. >     return md->md_size;
  308.   }
  309.   

crypto/evp/evp_lib.c:308:1: return from a call to EVP_MD_size
  306.       }
  307.       return md->md_size;
  308. > }
  309.   
  310.   unsigned long EVP_MD_flags(const EVP_MD *md)

crypto/rsa/rsa_oaep.c:256:9: Taking false branch
254.           goto err;
255.       mdlen = EVP_MD_size(dgst);
256.       if (mdlen < 0)
               ^
257.           goto err;
258.       for (i = 0; outlen < len; i++) {

crypto/rsa/rsa_oaep.c:258:10: 
256.       if (mdlen < 0)
257.           goto err;
258. >     for (i = 0; outlen < len; i++) {
259.           cnt[0] = (unsigned char)((i >> 24) & 255);
260.           cnt[1] = (unsigned char)((i >> 16) & 255);

crypto/rsa/rsa_oaep.c:258:17: Loop condition is true. Entering loop body
256.       if (mdlen < 0)
257.           goto err;
258.       for (i = 0; outlen < len; i++) {
                       ^
259.           cnt[0] = (unsigned char)((i >> 24) & 255);
260.           cnt[1] = (unsigned char)((i >> 16) & 255);

crypto/rsa/rsa_oaep.c:259:9: 
257.           goto err;
258.       for (i = 0; outlen < len; i++) {
259. >         cnt[0] = (unsigned char)((i >> 24) & 255);
260.           cnt[1] = (unsigned char)((i >> 16) & 255);
261.           cnt[2] = (unsigned char)((i >> 8)) & 255;

crypto/rsa/rsa_oaep.c:260:9: 
258.       for (i = 0; outlen < len; i++) {
259.           cnt[0] = (unsigned char)((i >> 24) & 255);
260. >         cnt[1] = (unsigned char)((i >> 16) & 255);
261.           cnt[2] = (unsigned char)((i >> 8)) & 255;
262.           cnt[3] = (unsigned char)(i & 255);

crypto/rsa/rsa_oaep.c:261:9: 
259.           cnt[0] = (unsigned char)((i >> 24) & 255);
260.           cnt[1] = (unsigned char)((i >> 16) & 255);
261. >         cnt[2] = (unsigned char)((i >> 8)) & 255;
262.           cnt[3] = (unsigned char)(i & 255);
263.           if (!EVP_DigestInit_ex(c, dgst, NULL)

crypto/rsa/rsa_oaep.c:262:9: 
260.           cnt[1] = (unsigned char)((i >> 16) & 255);
261.           cnt[2] = (unsigned char)((i >> 8)) & 255;
262. >         cnt[3] = (unsigned char)(i & 255);
263.           if (!EVP_DigestInit_ex(c, dgst, NULL)
264.               || !EVP_DigestUpdate(c, seed, seedlen)

crypto/rsa/rsa_oaep.c:263:14: Taking false branch
261.           cnt[2] = (unsigned char)((i >> 8)) & 255;
262.           cnt[3] = (unsigned char)(i & 255);
263.           if (!EVP_DigestInit_ex(c, dgst, NULL)
                    ^
264.               || !EVP_DigestUpdate(c, seed, seedlen)
265.               || !EVP_DigestUpdate(c, cnt, 4))

crypto/rsa/rsa_oaep.c:264:17: 
262.           cnt[3] = (unsigned char)(i & 255);
263.           if (!EVP_DigestInit_ex(c, dgst, NULL)
264. >             || !EVP_DigestUpdate(c, seed, seedlen)
265.               || !EVP_DigestUpdate(c, cnt, 4))
266.               goto err;

crypto/evp/digest.c:146:1: start of procedure EVP_DigestUpdate()
  144.   }
  145.   
  146. > int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  147.   {
  148.       return ctx->update(ctx, data, count);

crypto/evp/digest.c:148:5: Skipping __function_pointer__(): unresolved function pointer
  146.   int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
  147.   {
  148.       return ctx->update(ctx, data, count);
             ^
  149.   }
  150.   

crypto/evp/digest.c:149:1: return from a call to EVP_DigestUpdate
  147.   {
  148.       return ctx->update(ctx, data, count);
  149. > }
  150.   
  151.   /* The caller can assume that this removes any secret data from the context */

crypto/rsa/rsa_oaep.c:264:17: Taking true branch
262.           cnt[3] = (unsigned char)(i & 255);
263.           if (!EVP_DigestInit_ex(c, dgst, NULL)
264.               || !EVP_DigestUpdate(c, seed, seedlen)
                       ^
265.               || !EVP_DigestUpdate(c, cnt, 4))
266.               goto err;

crypto/rsa/rsa_oaep.c:279:2: 
277.       }
278.       rv = 0;
279. >  err:
280.       EVP_MD_CTX_free(c);
281.       return rv;

crypto/rsa/rsa_oaep.c:280:5: 
278.       rv = 0;
279.    err:
280. >     EVP_MD_CTX_free(c);
281.       return rv;
282.   }

crypto/evp/digest.c:49:1: start of procedure EVP_MD_CTX_free()
  47.   }
  48.   
  49. > void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);

crypto/evp/digest.c:51:5: Skipping EVP_MD_CTX_reset(): empty list of specs
  49.   void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
            ^
  52.       OPENSSL_free(ctx);
  53.   }

crypto/evp/digest.c:52:5: 
  50.   {
  51.       EVP_MD_CTX_reset(ctx);
  52. >     OPENSSL_free(ctx);
  53.   }
  54.   

crypto/mem.c:163:1: start of procedure CRYPTO_free()
    161.   }
    162.   
    163. > void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:165:9: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:165:30: Taking true branch
    163.   void CRYPTO_free(void *str, const char *file, int line)
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    166.           free_impl(str, file, line);
    167.           return;

crypto/mem.c:166:9: Skipping __function_pointer__(): unresolved function pointer
    164.   {
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
                   ^
    167.           return;
    168.       }

crypto/mem.c:167:9: 
    165.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    166.           free_impl(str, file, line);
    167. >         return;
    168.       }
    169.   

crypto/mem.c:181:1: return from a call to CRYPTO_free
    179.       free(str);
    180.   #endif
    181. > }
    182.   
    183.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/evp/digest.c:53:1: return from a call to EVP_MD_CTX_free
  51.       EVP_MD_CTX_reset(ctx);
  52.       OPENSSL_free(ctx);
  53. > }
  54.   
  55.   int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)

int PKCS1_MGF1(unsigned char *mask, long len,
               const unsigned char *seed, long seedlen, const EVP_MD *dgst)
{
    long i, outlen = 0;
    unsigned char cnt[4];
    EVP_MD_CTX *c = EVP_MD_CTX_new();
    unsigned char md[EVP_MAX_MD_SIZE];
    int mdlen;
    int rv = -1;
    if (c == NULL)
        goto err;
    mdlen = EVP_MD_size(dgst);
    if (mdlen < 0)
        goto err;
    for (i = 0; outlen < len; i++) {
        cnt[0] = (unsigned char)((i >> 24) & 255);
        cnt[1] = (unsigned char)((i >> 16) & 255);
        cnt[2] = (unsigned char)((i >> 8)) & 255;
        cnt[3] = (unsigned char)(i & 255);
        if (!EVP_DigestInit_ex(c, dgst, NULL)
            || !EVP_DigestUpdate(c, seed, seedlen)
            || !EVP_DigestUpdate(c, cnt, 4))
            goto err;
        if (outlen + mdlen <= len) {
            if (!EVP_DigestFinal_ex(c, mask + outlen, NULL))
                goto err;
            outlen += mdlen;
        } else {
            if (!EVP_DigestFinal_ex(c, md, NULL))
                goto err;
            memcpy(mask + outlen, md, len - outlen);
            outlen = len;
        }
    }
    rv = 0;
 err:
    EVP_MD_CTX_free(c);
    return rv;
}
['int PKCS1_MGF1(unsigned char *mask, long len,\n               const unsigned char *seed, long seedlen, const EVP_MD *dgst)\n{\n    long i, outlen = 0;\n    unsigned char cnt[4];\n    EVP_MD_CTX *c = EVP_MD_CTX_new();\n    unsigned char md[EVP_MAX_MD_SIZE];\n    int mdlen;\n    int rv = -1;\n    if (c == NULL)\n        goto err;\n    mdlen = EVP_MD_size(dgst);\n    if (mdlen < 0)\n        goto err;\n    for (i = 0; outlen < len; i++) {\n        cnt[0] = (unsigned char)((i >> 24) & 255);\n        cnt[1] = (unsigned char)((i >> 16) & 255);\n        cnt[2] = (unsigned char)((i >> 8)) & 255;\n        cnt[3] = (unsigned char)(i & 255);\n        if (!EVP_DigestInit_ex(c, dgst, NULL)\n            || !EVP_DigestUpdate(c, seed, seedlen)\n            || !EVP_DigestUpdate(c, cnt, 4))\n            goto err;\n        if (outlen + mdlen <= len) {\n            if (!EVP_DigestFinal_ex(c, mask + outlen, NULL))\n                goto err;\n            outlen += mdlen;\n        } else {\n            if (!EVP_DigestFinal_ex(c, md, NULL))\n                goto err;\n            memcpy(mask + outlen, md, len - outlen);\n            outlen = len;\n        }\n    }\n    rv = 0;\n err:\n    EVP_MD_CTX_free(c);\n    return rv;\n}', 'EVP_MD_CTX *EVP_MD_CTX_new(void)\n{\n    return OPENSSL_zalloc(sizeof(EVP_MD_CTX));\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\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    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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int EVP_MD_size(const EVP_MD *md)\n{\n    if (!md) {\n        EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);\n        return -1;\n    }\n    return md->md_size;\n}', 'int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)\n{\n    return ctx->update(ctx, data, count);\n}', 'void EVP_MD_CTX_free(EVP_MD_CTX *ctx)\n{\n    EVP_MD_CTX_reset(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']