crypto/kdf/tls1_prf.c:341: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_malloc()` at line 335, column 20 is not reachable after line 341, column 13.
Showing all 46 steps of the trace


crypto/kdf/tls1_prf.c:318:1: start of procedure tls1_prf_alg()
316.    *   PRF(secret, label, seed) = P_<hash>(secret, label + seed)
317.    */
318. > static int tls1_prf_alg(const EVP_MD *md,
319.                           const unsigned char *sec, size_t slen,
320.                           const unsigned char *seed, size_t seed_len,

crypto/kdf/tls1_prf.c:323:9: 
321.                           unsigned char *out, size_t olen)
322.   {
323. >     if (EVP_MD_type(md) == NID_md5_sha1) {
324.           /* TLS v1.0 and TLS v1.1 */
325.           size_t i;

crypto/evp/evp_lib.c:415:1: start of procedure EVP_MD_type()
  413.   }
  414.   
  415. > int EVP_MD_type(const EVP_MD *md)
  416.   {
  417.       return md->type;

crypto/evp/evp_lib.c:417:5: 
  415.   int EVP_MD_type(const EVP_MD *md)
  416.   {
  417. >     return md->type;
  418.   }
  419.   

crypto/evp/evp_lib.c:418:1: return from a call to EVP_MD_type
  416.   {
  417.       return md->type;
  418. > }
  419.   
  420.   int EVP_MD_pkey_type(const EVP_MD *md)

crypto/kdf/tls1_prf.c:323:9: Taking true branch
321.                           unsigned char *out, size_t olen)
322.   {
323.       if (EVP_MD_type(md) == NID_md5_sha1) {
               ^
324.           /* TLS v1.0 and TLS v1.1 */
325.           size_t i;

crypto/kdf/tls1_prf.c:328:9: 
326.           unsigned char *tmp;
327.           /* calc: L_S1 = L_S2 = ceil(L_S / 2) */
328. >         size_t L_S1 = (slen + 1) / 2;
329.           size_t L_S2 = L_S1;
330.   

crypto/kdf/tls1_prf.c:329:9: 
327.           /* calc: L_S1 = L_S2 = ceil(L_S / 2) */
328.           size_t L_S1 = (slen + 1) / 2;
329. >         size_t L_S2 = L_S1;
330.   
331.           if (!tls1_prf_P_hash(EVP_md5(), sec, L_S1,

crypto/kdf/tls1_prf.c:331:14: 
329.           size_t L_S2 = L_S1;
330.   
331. >         if (!tls1_prf_P_hash(EVP_md5(), sec, L_S1,
332.                                seed, seed_len, out, olen))
333.               return 0;

crypto/evp/m_md5.c:51:1: start of procedure EVP_md5()
  49.   };
  50.   
  51. > const EVP_MD *EVP_md5(void)
  52.   {
  53.       return &md5_md;

crypto/evp/m_md5.c:53:5: 
  51.   const EVP_MD *EVP_md5(void)
  52.   {
  53. >     return &md5_md;
  54.   }
  55.   #endif

crypto/evp/m_md5.c:54:1: return from a call to EVP_md5
  52.   {
  53.       return &md5_md;
  54. > }
  55.   #endif

crypto/kdf/tls1_prf.c:331:14: Taking false branch
329.           size_t L_S2 = L_S1;
330.   
331.           if (!tls1_prf_P_hash(EVP_md5(), sec, L_S1,
                    ^
332.                                seed, seed_len, out, olen))
333.               return 0;

crypto/kdf/tls1_prf.c:335:13: 
333.               return 0;
334.   
335. >         if ((tmp = OPENSSL_malloc(olen)) == NULL) {
336.               KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
337.               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 false branch
  202.   
  203.       FAILTEST();
  204.       if (allow_customize) {
                 ^
  205.           /*
  206.            * Disallow customization after the first allocation. We only set this

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/kdf/tls1_prf.c:335:13: Taking false branch
333.               return 0;
334.   
335.           if ((tmp = OPENSSL_malloc(olen)) == NULL) {
                   ^
336.               KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
337.               return 0;

crypto/kdf/tls1_prf.c:339:14: 
337.               return 0;
338.           }
339. >         if (!tls1_prf_P_hash(EVP_sha1(), sec + slen - L_S2, L_S2,
340.                                seed, seed_len, tmp, olen)) {
341.               OPENSSL_clear_free(tmp, olen);

crypto/evp/m_sha1.c:109:1: start of procedure EVP_sha1()
  107.   };
  108.   
  109. > const EVP_MD *EVP_sha1(void)
  110.   {
  111.       return &sha1_md;

crypto/evp/m_sha1.c:111:5: 
  109.   const EVP_MD *EVP_sha1(void)
  110.   {
  111. >     return &sha1_md;
  112.   }
  113.   

crypto/evp/m_sha1.c:112:1: return from a call to EVP_sha1
  110.   {
  111.       return &sha1_md;
  112. > }
  113.   
  114.   static int init224(EVP_MD_CTX *ctx)

crypto/kdf/tls1_prf.c:339:14: Taking true branch
337.               return 0;
338.           }
339.           if (!tls1_prf_P_hash(EVP_sha1(), sec + slen - L_S2, L_S2,
                    ^
340.                                seed, seed_len, tmp, olen)) {
341.               OPENSSL_clear_free(tmp, olen);

crypto/kdf/tls1_prf.c:341:13: 
339.           if (!tls1_prf_P_hash(EVP_sha1(), sec + slen - L_S2, L_S2,
340.                                seed, seed_len, tmp, olen)) {
341. >             OPENSSL_clear_free(tmp, olen);
342.               return 0;
343.           }

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

static int tls1_prf_alg(const EVP_MD *md,
                        const unsigned char *sec, size_t slen,
                        const unsigned char *seed, size_t seed_len,
                        unsigned char *out, size_t olen)
{
    if (EVP_MD_type(md) == NID_md5_sha1) {
        size_t i;
        unsigned char *tmp;
        size_t L_S1 = (slen + 1) / 2;
        size_t L_S2 = L_S1;
        if (!tls1_prf_P_hash(EVP_md5(), sec, L_S1,
                             seed, seed_len, out, olen))
            return 0;
        if ((tmp = OPENSSL_malloc(olen)) == NULL) {
            KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);
            return 0;
        }
        if (!tls1_prf_P_hash(EVP_sha1(), sec + slen - L_S2, L_S2,
                             seed, seed_len, tmp, olen)) {
            OPENSSL_clear_free(tmp, olen);
            return 0;
        }
        for (i = 0; i < olen; i++)
            out[i] ^= tmp[i];
        OPENSSL_clear_free(tmp, olen);
        return 1;
    }
    if (!tls1_prf_P_hash(md, sec, slen, seed, seed_len, out, olen))
        return 0;
    return 1;
}
['static int tls1_prf_alg(const EVP_MD *md,\n                        const unsigned char *sec, size_t slen,\n                        const unsigned char *seed, size_t seed_len,\n                        unsigned char *out, size_t olen)\n{\n    if (EVP_MD_type(md) == NID_md5_sha1) {\n        size_t i;\n        unsigned char *tmp;\n        size_t L_S1 = (slen + 1) / 2;\n        size_t L_S2 = L_S1;\n        if (!tls1_prf_P_hash(EVP_md5(), sec, L_S1,\n                             seed, seed_len, out, olen))\n            return 0;\n        if ((tmp = OPENSSL_malloc(olen)) == NULL) {\n            KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n        if (!tls1_prf_P_hash(EVP_sha1(), sec + slen - L_S2, L_S2,\n                             seed, seed_len, tmp, olen)) {\n            OPENSSL_clear_free(tmp, olen);\n            return 0;\n        }\n        for (i = 0; i < olen; i++)\n            out[i] ^= tmp[i];\n        OPENSSL_clear_free(tmp, olen);\n        return 1;\n    }\n    if (!tls1_prf_P_hash(md, sec, slen, seed, seed_len, out, olen))\n        return 0;\n    return 1;\n}', 'int EVP_MD_type(const EVP_MD *md)\n{\n    return md->type;\n}', 'const EVP_MD *EVP_md5(void)\n{\n    return &md5_md;\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}', 'const EVP_MD *EVP_sha1(void)\n{\n    return &sha1_md;\n}', 'void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return;\n    if (num)\n        OPENSSL_cleanse(str, num);\n    CRYPTO_free(str, file, line);\n}', 'void OPENSSL_cleanse(void *ptr, size_t len)\n{\n    memset_func(ptr, 0, len);\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#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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}']