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


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

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

crypto/rsa/rsa_oaep.c:247:5: 
245.       long i, outlen = 0;
246.       unsigned char cnt[4];
247. >     EVP_MD_CTX *c = EVP_MD_CTX_new();
248.       unsigned char md[EVP_MAX_MD_SIZE];
249.       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:218:1: start of procedure CRYPTO_zalloc()
    216.   }
    217.   
    218. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:220:5: 
    218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    219.   {
    220. >     void *ret = CRYPTO_malloc(num, file, line);
    221.   
    222.       FAILTEST();

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

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

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

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

crypto/mem.c:201:5: 
      199.   
      200.       FAILTEST();
      201. >     allow_customize = 0;
      202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:211:19: 
      209.       }
      210.   #else
      211. >     (void)(file); (void)(line);
      212.       ret = malloc(num);
      213.   #endif

crypto/mem.c:212:5: 
      210.   #else
      211.       (void)(file); (void)(line);
      212. >     ret = malloc(num);
      213.   #endif
      214.   

crypto/mem.c:215:5: 
      213.   #endif
      214.   
      215. >     return ret;
      216.   }
      217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
      214.   
      215.       return ret;
      216. > }
      217.   
      218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:223:9: Taking true branch
    221.   
    222.       FAILTEST();
    223.       if (ret != NULL)
                   ^
    224.           memset(ret, 0, num);
    225.       return ret;

crypto/mem.c:224:9: 
    222.       FAILTEST();
    223.       if (ret != NULL)
    224. >         memset(ret, 0, num);
    225.       return ret;
    226.   }

crypto/mem.c:225:5: 
    223.       if (ret != NULL)
    224.           memset(ret, 0, num);
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_zalloc
    224.           memset(ret, 0, num);
    225.       return ret;
    226. > }
    227.   
    228.   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:250:5: 
248.       unsigned char md[EVP_MAX_MD_SIZE];
249.       int mdlen;
250. >     int rv = -1;
251.   
252.       if (c == NULL)

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

crypto/rsa/rsa_oaep.c:254:5: 
252.       if (c == NULL)
253.           goto err;
254. >     mdlen = EVP_MD_size(dgst);
255.       if (mdlen < 0)
256.           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:255:9: Taking false branch
253.           goto err;
254.       mdlen = EVP_MD_size(dgst);
255.       if (mdlen < 0)
               ^
256.           goto err;
257.       for (i = 0; outlen < len; i++) {

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

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

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

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

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

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

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

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

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

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

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:286:1: start of procedure CRYPTO_free()
    284.   }
    285.   
    286. > void CRYPTO_free(void *str, const char *file, int line)
    287.   {
    288.       INCREMENT(free_count);

crypto/mem.c:289:9: Taking true branch
    287.   {
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    290.           free_impl(str, file, line);
    291.           return;

crypto/mem.c:289:30: Taking true branch
    287.   {
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    290.           free_impl(str, file, line);
    291.           return;

crypto/mem.c:290:9: Skipping __function_pointer__(): unresolved function pointer
    288.       INCREMENT(free_count);
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    290.           free_impl(str, file, line);
                   ^
    291.           return;
    292.       }

crypto/mem.c:291:9: 
    289.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    290.           free_impl(str, file, line);
    291. >         return;
    292.       }
    293.   

crypto/mem.c:305:1: return from a call to CRYPTO_free
    303.       free(str);
    304.   #endif
    305. > }
    306.   
    307.   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    FAILTEST();\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    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\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    (void)(file); (void)(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    INCREMENT(free_count);\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}']