ssl/tls13_enc.c:635: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 612, column 23 is not reachable after line 635, column 5.
Showing all 58 steps of the trace


ssl/tls13_enc.c:603:1: start of procedure tls13_export_keying_material()
601.   }
602.   
603. > int tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen,
604.                                    const char *label, size_t llen,
605.                                    const unsigned char *context,

ssl/tls13_enc.c:609:5: 
607.   {
608.       unsigned char exportsecret[EVP_MAX_MD_SIZE];
609. >     static const unsigned char exporterlabel[] = "exporter";
610.       unsigned char hash[EVP_MAX_MD_SIZE];
611.       const EVP_MD *md = ssl_handshake_md(s);

ssl/tls13_enc.c:611:5: 
609.       static const unsigned char exporterlabel[] = "exporter";
610.       unsigned char hash[EVP_MAX_MD_SIZE];
611. >     const EVP_MD *md = ssl_handshake_md(s);
612.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
613.       unsigned int hashsize;

test/tls13secretstest.c:171:1: start of procedure ssl_handshake_md()
  169.   }
  170.   
  171. > const EVP_MD *ssl_handshake_md(SSL *s)
  172.   {
  173.       return EVP_sha256();

test/tls13secretstest.c:173:5: 
  171.   const EVP_MD *ssl_handshake_md(SSL *s)
  172.   {
  173. >     return EVP_sha256();
  174.   }
  175.   

crypto/evp/m_sha1.c:171:1: start of procedure EVP_sha256()
    169.   };
    170.   
    171. > const EVP_MD *EVP_sha256(void)
    172.   {
    173.       return (&sha256_md);

crypto/evp/m_sha1.c:173:5: 
    171.   const EVP_MD *EVP_sha256(void)
    172.   {
    173. >     return (&sha256_md);
    174.   }
    175.   

crypto/evp/m_sha1.c:174:1: return from a call to EVP_sha256
    172.   {
    173.       return (&sha256_md);
    174. > }
    175.   
    176.   static int init384(EVP_MD_CTX *ctx)

test/tls13secretstest.c:174:1: return from a call to ssl_handshake_md
  172.   {
  173.       return EVP_sha256();
  174. > }
  175.   
  176.   void RECORD_LAYER_reset_read_sequence(RECORD_LAYER *rl)

ssl/tls13_enc.c:612:5: 
610.       unsigned char hash[EVP_MAX_MD_SIZE];
611.       const EVP_MD *md = ssl_handshake_md(s);
612. >     EVP_MD_CTX *ctx = EVP_MD_CTX_new();
613.       unsigned int hashsize;
614.       int ret = 0;

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:197:1: start of procedure CRYPTO_zalloc()
    195.   }
    196.   
    197. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:199:5: 
    197.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    198.   {
    199. >     void *ret = CRYPTO_malloc(num, file, line);
    200.   
    201.       FAILTEST();

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)

crypto/mem.c:202:9: Taking true branch
    200.   
    201.       FAILTEST();
    202.       if (ret != NULL)
                   ^
    203.           memset(ret, 0, num);
    204.       return ret;

crypto/mem.c:203:9: 
    201.       FAILTEST();
    202.       if (ret != NULL)
    203. >         memset(ret, 0, num);
    204.       return ret;
    205.   }

crypto/mem.c:204:5: 
    202.       if (ret != NULL)
    203.           memset(ret, 0, num);
    204. >     return ret;
    205.   }
    206.   

crypto/mem.c:205:1: return from a call to CRYPTO_zalloc
    203.           memset(ret, 0, num);
    204.       return ret;
    205. > }
    206.   
    207.   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)

ssl/tls13_enc.c:614:5: 
612.       EVP_MD_CTX *ctx = EVP_MD_CTX_new();
613.       unsigned int hashsize;
614. >     int ret = 0;
615.   
616.       if (ctx == NULL || !SSL_is_init_finished(s))

ssl/tls13_enc.c:616:9: Taking false branch
614.       int ret = 0;
615.   
616.       if (ctx == NULL || !SSL_is_init_finished(s))
               ^
617.           goto err;
618.   

ssl/tls13_enc.c:616:25: 
614.       int ret = 0;
615.   
616. >     if (ctx == NULL || !SSL_is_init_finished(s))
617.           goto err;
618.   

ssl/statem/statem.c:74:1: start of procedure SSL_is_init_finished()
  72.   }
  73.   
  74. > int SSL_is_init_finished(SSL *s)
  75.   {
  76.       return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);

ssl/statem/statem.c:76:13: Condition is true
  74.   int SSL_is_init_finished(SSL *s)
  75.   {
  76.       return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
                    ^
  77.   }
  78.   

ssl/statem/statem.c:76:37: Condition is true
  74.   int SSL_is_init_finished(SSL *s)
  75.   {
  76.       return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
                                            ^
  77.   }
  78.   

ssl/statem/statem.c:76:12: 
  74.   int SSL_is_init_finished(SSL *s)
  75.   {
  76. >     return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
  77.   }
  78.   

ssl/statem/statem.c:76:5: 
  74.   int SSL_is_init_finished(SSL *s)
  75.   {
  76. >     return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
  77.   }
  78.   

ssl/statem/statem.c:77:1: return from a call to SSL_is_init_finished
  75.   {
  76.       return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);
  77. > }
  78.   
  79.   int SSL_in_before(SSL *s)

ssl/tls13_enc.c:616:25: Taking false branch
614.       int ret = 0;
615.   
616.       if (ctx == NULL || !SSL_is_init_finished(s))
                               ^
617.           goto err;
618.   

ssl/tls13_enc.c:619:10: Taking false branch
617.           goto err;
618.   
619.       if (!use_context)
                ^
620.           contextlen = 0;
621.   

ssl/tls13_enc.c:622:9: Taking false branch
620.           contextlen = 0;
621.   
622.       if (EVP_DigestInit_ex(ctx, md, NULL) <= 0
               ^
623.               || EVP_DigestUpdate(ctx, context, contextlen) <= 0
624.               || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0

ssl/tls13_enc.c:623:16: 
621.   
622.       if (EVP_DigestInit_ex(ctx, md, NULL) <= 0
623. >             || EVP_DigestUpdate(ctx, context, contextlen) <= 0
624.               || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0
625.               || !tls13_hkdf_expand(s, md, s->exporter_master_secret,

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 */

ssl/tls13_enc.c:623:16: Taking true branch
621.   
622.       if (EVP_DigestInit_ex(ctx, md, NULL) <= 0
623.               || EVP_DigestUpdate(ctx, context, contextlen) <= 0
                      ^
624.               || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0
625.               || !tls13_hkdf_expand(s, md, s->exporter_master_secret,

ssl/tls13_enc.c:634:2: 
632.   
633.       ret = 1;
634. >  err:
635.       EVP_MD_CTX_free(ctx);
636.       return ret;

ssl/tls13_enc.c:635:5: 
633.       ret = 1;
634.    err:
635. >     EVP_MD_CTX_free(ctx);
636.       return ret;
637.   }

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: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/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 tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen,
                                 const char *label, size_t llen,
                                 const unsigned char *context,
                                 size_t contextlen, int use_context)
{
    unsigned char exportsecret[EVP_MAX_MD_SIZE];
    static const unsigned char exporterlabel[] = "exporter";
    unsigned char hash[EVP_MAX_MD_SIZE];
    const EVP_MD *md = ssl_handshake_md(s);
    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    unsigned int hashsize;
    int ret = 0;
    if (ctx == NULL || !SSL_is_init_finished(s))
        goto err;
    if (!use_context)
        contextlen = 0;
    if (EVP_DigestInit_ex(ctx, md, NULL) <= 0
            || EVP_DigestUpdate(ctx, context, contextlen) <= 0
            || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0
            || !tls13_hkdf_expand(s, md, s->exporter_master_secret,
                                  (const unsigned char *)label, llen, NULL, 0,
                                  exportsecret, hashsize)
            || !tls13_hkdf_expand(s, md, exportsecret, exporterlabel,
                                  sizeof(exporterlabel) - 1, hash, hashsize,
                                  out, olen))
        goto err;
    ret = 1;
 err:
    EVP_MD_CTX_free(ctx);
    return ret;
}
['int tls13_export_keying_material(SSL *s, unsigned char *out, size_t olen,\n                                 const char *label, size_t llen,\n                                 const unsigned char *context,\n                                 size_t contextlen, int use_context)\n{\n    unsigned char exportsecret[EVP_MAX_MD_SIZE];\n    static const unsigned char exporterlabel[] = "exporter";\n    unsigned char hash[EVP_MAX_MD_SIZE];\n    const EVP_MD *md = ssl_handshake_md(s);\n    EVP_MD_CTX *ctx = EVP_MD_CTX_new();\n    unsigned int hashsize;\n    int ret = 0;\n    if (ctx == NULL || !SSL_is_init_finished(s))\n        goto err;\n    if (!use_context)\n        contextlen = 0;\n    if (EVP_DigestInit_ex(ctx, md, NULL) <= 0\n            || EVP_DigestUpdate(ctx, context, contextlen) <= 0\n            || EVP_DigestFinal_ex(ctx, hash, &hashsize) <= 0\n            || !tls13_hkdf_expand(s, md, s->exporter_master_secret,\n                                  (const unsigned char *)label, llen, NULL, 0,\n                                  exportsecret, hashsize)\n            || !tls13_hkdf_expand(s, md, exportsecret, exporterlabel,\n                                  sizeof(exporterlabel) - 1, hash, hashsize,\n                                  out, olen))\n        goto err;\n    ret = 1;\n err:\n    EVP_MD_CTX_free(ctx);\n    return ret;\n}', 'const EVP_MD *ssl_handshake_md(SSL *s)\n{\n    return EVP_sha256();\n}', 'const EVP_MD *EVP_sha256(void)\n{\n    return (&sha256_md);\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    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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int SSL_is_init_finished(SSL *s)\n{\n    return !(s->statem.in_init) && (s->statem.hand_state == TLS_ST_OK);\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}']