ssl/s3_enc.c:75: error: MEMORY_LEAK
  memory dynamically allocated by call to `EVP_MD_CTX_new()` at line 31, column 10 is not reachable after line 75, column 5.
Showing all 86 steps of the trace


ssl/s3_enc.c:17:1: start of procedure ssl3_generate_key_block()
15.   #include "internal/cryptlib.h"
16.   
17. > static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
18.   {
19.       EVP_MD_CTX *m5;

ssl/s3_enc.c:22:5: 
20.       EVP_MD_CTX *s1;
21.       unsigned char buf[16], smd[SHA_DIGEST_LENGTH];
22. >     unsigned char c = 'A';
23.       unsigned int i, j, k;
24.       int ret = 0;

ssl/s3_enc.c:24:5: 
22.       unsigned char c = 'A';
23.       unsigned int i, j, k;
24. >     int ret = 0;
25.   
26.   #ifdef CHARSET_EBCDIC

ssl/s3_enc.c:29:5: 
27.       c = os_toascii[c];          /* 'A' in ASCII */
28.   #endif
29. >     k = 0;
30.       m5 = EVP_MD_CTX_new();
31.       s1 = EVP_MD_CTX_new();

ssl/s3_enc.c:30:5: 
28.   #endif
29.       k = 0;
30. >     m5 = EVP_MD_CTX_new();
31.       s1 = EVP_MD_CTX_new();
32.       if (m5 == NULL || s1 == NULL) {

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/s3_enc.c:31:5: 
29.       k = 0;
30.       m5 = EVP_MD_CTX_new();
31. >     s1 = EVP_MD_CTX_new();
32.       if (m5 == NULL || s1 == NULL) {
33.           SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);

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/s3_enc.c:32:9: Taking false branch
30.       m5 = EVP_MD_CTX_new();
31.       s1 = EVP_MD_CTX_new();
32.       if (m5 == NULL || s1 == NULL) {
              ^
33.           SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
34.           goto err;

ssl/s3_enc.c:32:23: Taking false branch
30.       m5 = EVP_MD_CTX_new();
31.       s1 = EVP_MD_CTX_new();
32.       if (m5 == NULL || s1 == NULL) {
                            ^
33.           SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
34.           goto err;

ssl/s3_enc.c:36:5: 
34.           goto err;
35.       }
36. >     EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
37.       for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
38.           k++;

crypto/evp/evp_lib.c:469:1: start of procedure EVP_MD_CTX_set_flags()
  467.   }
  468.   
  469. > void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
  470.   {
  471.       ctx->flags |= flags;

crypto/evp/evp_lib.c:471:5: 
  469.   void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)
  470.   {
  471. >     ctx->flags |= flags;
  472.   }
  473.   

crypto/evp/evp_lib.c:472:1: return from a call to EVP_MD_CTX_set_flags
  470.   {
  471.       ctx->flags |= flags;
  472. > }
  473.   
  474.   void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags)

ssl/s3_enc.c:37:10: 
35.       }
36.       EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
37. >     for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
38.           k++;
39.           if (k > sizeof(buf)) {

ssl/s3_enc.c:37:17: Loop condition is true. Entering loop body
35.       }
36.       EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
37.       for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
                      ^
38.           k++;
39.           if (k > sizeof(buf)) {

ssl/s3_enc.c:38:9: 
36.       EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
37.       for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
38. >         k++;
39.           if (k > sizeof(buf)) {
40.               /* bug: 'buf' is too small for this ciphersuite */

ssl/s3_enc.c:39:13: Taking false branch
37.       for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
38.           k++;
39.           if (k > sizeof(buf)) {
                  ^
40.               /* bug: 'buf' is too small for this ciphersuite */
41.               SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_INTERNAL_ERROR);

ssl/s3_enc.c:45:14: 
43.           }
44.   
45. >         for (j = 0; j < k; j++)
46.               buf[j] = c;
47.           c++;

ssl/s3_enc.c:45:21: Loop condition is true. Entering loop body
43.           }
44.   
45.           for (j = 0; j < k; j++)
                          ^
46.               buf[j] = c;
47.           c++;

ssl/s3_enc.c:46:13: 
44.   
45.           for (j = 0; j < k; j++)
46. >             buf[j] = c;
47.           c++;
48.           if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)

ssl/s3_enc.c:45:28: 
43.           }
44.   
45. >         for (j = 0; j < k; j++)
46.               buf[j] = c;
47.           c++;

ssl/s3_enc.c:45:21: Loop condition is false. Leaving loop
43.           }
44.   
45.           for (j = 0; j < k; j++)
                          ^
46.               buf[j] = c;
47.           c++;

ssl/s3_enc.c:47:9: 
45.           for (j = 0; j < k; j++)
46.               buf[j] = c;
47. >         c++;
48.           if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)
49.               || !EVP_DigestUpdate(s1, buf, k)

ssl/s3_enc.c:48:14: 
46.               buf[j] = c;
47.           c++;
48. >         if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)
49.               || !EVP_DigestUpdate(s1, buf, k)
50.               || !EVP_DigestUpdate(s1, s->session->master_key,

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

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

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

ssl/s3_enc.c:48:14: Taking true branch
46.               buf[j] = c;
47.           c++;
48.           if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)
                   ^
49.               || !EVP_DigestUpdate(s1, buf, k)
50.               || !EVP_DigestUpdate(s1, s->session->master_key,

ssl/s3_enc.c:73:2: 
71.       OPENSSL_cleanse(smd, sizeof(smd));
72.       ret = 1;
73. >  err:
74.       EVP_MD_CTX_free(m5);
75.       EVP_MD_CTX_free(s1);

ssl/s3_enc.c:74:5: 
72.       ret = 1;
73.    err:
74. >     EVP_MD_CTX_free(m5);
75.       EVP_MD_CTX_free(s1);
76.       return ret;

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 false 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:280:5: 
    278.       }
    279.   #else
    280. >     free(str);
    281.   #endif
    282.   }

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)

ssl/s3_enc.c:75:5: 
73.    err:
74.       EVP_MD_CTX_free(m5);
75. >     EVP_MD_CTX_free(s1);
76.       return ret;
77.   }

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)

static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
{
    EVP_MD_CTX *m5;
    EVP_MD_CTX *s1;
    unsigned char buf[16], smd[SHA_DIGEST_LENGTH];
    unsigned char c = 'A';
    unsigned int i, j, k;
    int ret = 0;
#ifdef CHARSET_EBCDIC
    c = os_toascii[c];
#endif
    k = 0;
    m5 = EVP_MD_CTX_new();
    s1 = EVP_MD_CTX_new();
    if (m5 == NULL || s1 == NULL) {
        SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
    for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
        k++;
        if (k > sizeof(buf)) {
            SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_INTERNAL_ERROR);
            goto err;
        }
        for (j = 0; j < k; j++)
            buf[j] = c;
        c++;
        if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)
            || !EVP_DigestUpdate(s1, buf, k)
            || !EVP_DigestUpdate(s1, s->session->master_key,
                                 s->session->master_key_length)
            || !EVP_DigestUpdate(s1, s->s3->server_random, SSL3_RANDOM_SIZE)
            || !EVP_DigestUpdate(s1, s->s3->client_random, SSL3_RANDOM_SIZE)
            || !EVP_DigestFinal_ex(s1, smd, NULL)
            || !EVP_DigestInit_ex(m5, EVP_md5(), NULL)
            || !EVP_DigestUpdate(m5, s->session->master_key,
                                 s->session->master_key_length)
            || !EVP_DigestUpdate(m5, smd, SHA_DIGEST_LENGTH))
            goto err;
        if ((int)(i + MD5_DIGEST_LENGTH) > num) {
            if (!EVP_DigestFinal_ex(m5, smd, NULL))
                goto err;
            memcpy(km, smd, (num - i));
        } else {
            if (!EVP_DigestFinal_ex(m5, km, NULL))
                goto err;
        }
        km += MD5_DIGEST_LENGTH;
    }
    OPENSSL_cleanse(smd, sizeof(smd));
    ret = 1;
 err:
    EVP_MD_CTX_free(m5);
    EVP_MD_CTX_free(s1);
    return ret;
}
["static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)\n{\n    EVP_MD_CTX *m5;\n    EVP_MD_CTX *s1;\n    unsigned char buf[16], smd[SHA_DIGEST_LENGTH];\n    unsigned char c = 'A';\n    unsigned int i, j, k;\n    int ret = 0;\n#ifdef CHARSET_EBCDIC\n    c = os_toascii[c];\n#endif\n    k = 0;\n    m5 = EVP_MD_CTX_new();\n    s1 = EVP_MD_CTX_new();\n    if (m5 == NULL || s1 == NULL) {\n        SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);\n    for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {\n        k++;\n        if (k > sizeof(buf)) {\n            SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_INTERNAL_ERROR);\n            goto err;\n        }\n        for (j = 0; j < k; j++)\n            buf[j] = c;\n        c++;\n        if (!EVP_DigestInit_ex(s1, EVP_sha1(), NULL)\n            || !EVP_DigestUpdate(s1, buf, k)\n            || !EVP_DigestUpdate(s1, s->session->master_key,\n                                 s->session->master_key_length)\n            || !EVP_DigestUpdate(s1, s->s3->server_random, SSL3_RANDOM_SIZE)\n            || !EVP_DigestUpdate(s1, s->s3->client_random, SSL3_RANDOM_SIZE)\n            || !EVP_DigestFinal_ex(s1, smd, NULL)\n            || !EVP_DigestInit_ex(m5, EVP_md5(), NULL)\n            || !EVP_DigestUpdate(m5, s->session->master_key,\n                                 s->session->master_key_length)\n            || !EVP_DigestUpdate(m5, smd, SHA_DIGEST_LENGTH))\n            goto err;\n        if ((int)(i + MD5_DIGEST_LENGTH) > num) {\n            if (!EVP_DigestFinal_ex(m5, smd, NULL))\n                goto err;\n            memcpy(km, smd, (num - i));\n        } else {\n            if (!EVP_DigestFinal_ex(m5, km, NULL))\n                goto err;\n        }\n        km += MD5_DIGEST_LENGTH;\n    }\n    OPENSSL_cleanse(smd, sizeof(smd));\n    ret = 1;\n err:\n    EVP_MD_CTX_free(m5);\n    EVP_MD_CTX_free(s1);\n    return ret;\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}', 'void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags)\n{\n    ctx->flags |= flags;\n}', 'const EVP_MD *EVP_sha1(void)\n{\n    return (&sha1_md);\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}']