crypto/pkcs7/pk7_doit.c:130: error: MEMORY_LEAK
  memory dynamically allocated by call to `BIO_new()` at line 107, column 17 is not reachable after line 130, column 5.
Showing all 92 steps of the trace


crypto/pkcs7/pk7_doit.c:103:1: start of procedure PKCS7_bio_add_digest()
101.   }
102.   
103. > static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)
104.   {
105.       BIO *btmp;

crypto/pkcs7/pk7_doit.c:107:9: 
105.       BIO *btmp;
106.       const EVP_MD *md;
107. >     if ((btmp = BIO_new(BIO_f_md())) == NULL) {
108.           PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);
109.           goto err;

crypto/evp/bio_md.c:93:1: start of procedure BIO_f_md()
  91.   };
  92.   
  93. > BIO_METHOD *BIO_f_md(void)
  94.   {
  95.       return (&methods_md);

crypto/evp/bio_md.c:95:5: 
  93.   BIO_METHOD *BIO_f_md(void)
  94.   {
  95. >     return (&methods_md);
  96.   }
  97.   

crypto/evp/bio_md.c:96:1: return from a call to BIO_f_md
  94.   {
  95.       return (&methods_md);
  96. > }
  97.   
  98.   static int md_new(BIO *bi)

crypto/bio/bio_lib.c:65:1: start of procedure BIO_new()
  63.   #include <openssl/stack.h>
  64.   
  65. > BIO *BIO_new(BIO_METHOD *method)
  66.   {
  67.       BIO *ret = OPENSSL_malloc(sizeof(*ret));

crypto/bio/bio_lib.c:67:5: 
  65.   BIO *BIO_new(BIO_METHOD *method)
  66.   {
  67. >     BIO *ret = OPENSSL_malloc(sizeof(*ret));
  68.   
  69.       if (ret == NULL) {

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (num <= 0)
                   ^
    124.           return NULL;
    125.   

crypto/mem.c:126:5: 
    124.           return NULL;
    125.   
    126. >     allow_customize = 0;
    127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
    134.       }
    135.   #else
    136. >     (void)file;
    137.       (void)line;
    138.       ret = malloc(num);

crypto/mem.c:137:5: 
    135.   #else
    136.       (void)file;
    137. >     (void)line;
    138.       ret = malloc(num);
    139.   #endif

crypto/mem.c:138:5: 
    136.       (void)file;
    137.       (void)line;
    138. >     ret = malloc(num);
    139.   #endif
    140.   

crypto/mem.c:153:5: 
    151.   #endif
    152.   
    153. >     return ret;
    154.   }
    155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
    152.   
    153.       return ret;
    154. > }
    155.   
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/bio/bio_lib.c:69:9: Taking false branch
  67.       BIO *ret = OPENSSL_malloc(sizeof(*ret));
  68.   
  69.       if (ret == NULL) {
                ^
  70.           BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
  71.           return (NULL);

crypto/bio/bio_lib.c:73:10: Taking false branch
  71.           return (NULL);
  72.       }
  73.       if (!BIO_set(ret, method)) {
                 ^
  74.           OPENSSL_free(ret);
  75.           ret = NULL;

crypto/bio/bio_lib.c:77:5: 
  75.           ret = NULL;
  76.       }
  77. >     return (ret);
  78.   }
  79.   

crypto/bio/bio_lib.c:78:1: return from a call to BIO_new
  76.       }
  77.       return (ret);
  78. > }
  79.   
  80.   int BIO_set(BIO *bio, BIO_METHOD *method)

crypto/pkcs7/pk7_doit.c:107:9: Taking false branch
105.       BIO *btmp;
106.       const EVP_MD *md;
107.       if ((btmp = BIO_new(BIO_f_md())) == NULL) {
               ^
108.           PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);
109.           goto err;

crypto/pkcs7/pk7_doit.c:112:5: 
110.       }
111.   
112. >     md = EVP_get_digestbyobj(alg->algorithm);
113.       if (md == NULL) {
114.           PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE);

crypto/objects/obj_dat.c:381:1: start of procedure OBJ_obj2nid()
  379.   IMPLEMENT_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj);
  380.   
  381. > int OBJ_obj2nid(const ASN1_OBJECT *a)
  382.   {
  383.       const unsigned int *op;

crypto/objects/obj_dat.c:386:9: Taking false branch
  384.       ADDED_OBJ ad, *adp;
  385.   
  386.       if (a == NULL)
                 ^
  387.           return (NID_undef);
  388.       if (a->nid != 0)

crypto/objects/obj_dat.c:388:9: Taking true branch
  386.       if (a == NULL)
  387.           return (NID_undef);
  388.       if (a->nid != 0)
                 ^
  389.           return (a->nid);
  390.   

crypto/objects/obj_dat.c:389:9: 
  387.           return (NID_undef);
  388.       if (a->nid != 0)
  389. >         return (a->nid);
  390.   
  391.       if (a->length == 0)

crypto/objects/obj_dat.c:405:1: return from a call to OBJ_obj2nid
  403.           return (NID_undef);
  404.       return (nid_objs[*op].nid);
  405. > }
  406.   
  407.   /*

crypto/objects/obj_dat.c:311:1: start of procedure OBJ_nid2sn()
  309.   }
  310.   
  311. > const char *OBJ_nid2sn(int n)
  312.   {
  313.       ADDED_OBJ ad, *adp;

crypto/objects/obj_dat.c:316:10: Taking true branch
  314.       ASN1_OBJECT ob;
  315.   
  316.       if ((n >= 0) && (n < NUM_NID)) {
                  ^
  317.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  318.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:316:22: Taking true branch
  314.       ASN1_OBJECT ob;
  315.   
  316.       if ((n >= 0) && (n < NUM_NID)) {
                              ^
  317.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
  318.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);

crypto/objects/obj_dat.c:317:14: Taking true branch
  315.   
  316.       if ((n >= 0) && (n < NUM_NID)) {
  317.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
                      ^
  318.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);
  319.               return (NULL);

crypto/objects/obj_dat.c:317:34: Taking false branch
  315.   
  316.       if ((n >= 0) && (n < NUM_NID)) {
  317.           if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {
                                          ^
  318.               OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);
  319.               return (NULL);

crypto/objects/obj_dat.c:321:9: 
  319.               return (NULL);
  320.           }
  321. >         return (nid_objs[n].sn);
  322.       } else if (added == NULL)
  323.           return (NULL);

crypto/objects/obj_dat.c:336:1: return from a call to OBJ_nid2sn
  334.           }
  335.       }
  336. > }
  337.   
  338.   const char *OBJ_nid2ln(int n)

crypto/evp/names.c:120:1: start of procedure EVP_get_digestbyname()
  118.   }
  119.   
  120. > const EVP_MD *EVP_get_digestbyname(const char *name)
  121.   {
  122.       const EVP_MD *cp;

crypto/evp/names.c:124:10: Taking false branch
  122.       const EVP_MD *cp;
  123.   
  124.       if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL))
                  ^
  125.           return NULL;
  126.   

crypto/evp/names.c:127:5: 
  125.           return NULL;
  126.   
  127. >     cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
  128.       return (cp);
  129.   }

crypto/objects/o_names.c:133:1: start of procedure OBJ_NAME_get()
    131.   }
    132.   
    133. > const char *OBJ_NAME_get(const char *name, int type)
    134.   {
    135.       OBJ_NAME on, *ret;

crypto/objects/o_names.c:136:5: 
    134.   {
    135.       OBJ_NAME on, *ret;
    136. >     int num = 0, alias;
    137.   
    138.       if (name == NULL)

crypto/objects/o_names.c:138:9: Taking false branch
    136.       int num = 0, alias;
    137.   
    138.       if (name == NULL)
                   ^
    139.           return (NULL);
    140.       if ((names_lh == NULL) && !OBJ_NAME_init())

crypto/objects/o_names.c:140:10: Taking false branch
    138.       if (name == NULL)
    139.           return (NULL);
    140.       if ((names_lh == NULL) && !OBJ_NAME_init())
                    ^
    141.           return (NULL);
    142.   

crypto/objects/o_names.c:143:5: 
    141.           return (NULL);
    142.   
    143. >     alias = type & OBJ_NAME_ALIAS;
    144.       type &= ~OBJ_NAME_ALIAS;
    145.   

crypto/objects/o_names.c:144:5: 
    142.   
    143.       alias = type & OBJ_NAME_ALIAS;
    144. >     type &= ~OBJ_NAME_ALIAS;
    145.   
    146.       on.name = name;

crypto/objects/o_names.c:146:5: 
    144.       type &= ~OBJ_NAME_ALIAS;
    145.   
    146. >     on.name = name;
    147.       on.type = type;
    148.   

crypto/objects/o_names.c:147:5: 
    145.   
    146.       on.name = name;
    147. >     on.type = type;
    148.   
    149.       for (;;) {

crypto/objects/o_names.c:160:5: Loop condition is true. Entering loop body
    158.               return (ret->data);
    159.           }
    160.       }
               ^
    161.   }
    162.   

crypto/objects/o_names.c:150:9: 
    148.   
    149.       for (;;) {
    150. >         ret = lh_OBJ_NAME_retrieve(names_lh, &on);
    151.           if (ret == NULL)
    152.               return (NULL);

crypto/objects/obj_lcl.h:5:1: start of procedure lh_OBJ_NAME_retrieve()
      3.   typedef struct name_funcs_st NAME_FUNCS;
      4.   DEFINE_STACK_OF(NAME_FUNCS)
      5. > DEFINE_LHASH_OF(OBJ_NAME);
      6.   typedef struct added_obj_st ADDED_OBJ;
      7.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/lhash/lhash.c:216:1: start of procedure lh_retrieve()
        214.   }
        215.   
        216. > void *lh_retrieve(_LHASH *lh, const void *data)
        217.   {
        218.       unsigned long hash;

crypto/lhash/lhash.c:222:5: 
        220.       void *ret;
        221.   
        222. >     lh->error = 0;
        223.       rn = getrn(lh, data, &hash);
        224.   

crypto/lhash/lhash.c:223:5: Skipping getrn(): empty list of specs
        221.   
        222.       lh->error = 0;
        223.       rn = getrn(lh, data, &hash);
                   ^
        224.   
        225.       if (*rn == NULL) {

crypto/lhash/lhash.c:225:9: Taking true branch
        223.       rn = getrn(lh, data, &hash);
        224.   
        225.       if (*rn == NULL) {
                       ^
        226.           lh->num_retrieve_miss++;
        227.           return (NULL);

crypto/lhash/lhash.c:226:9: 
        224.   
        225.       if (*rn == NULL) {
        226. >         lh->num_retrieve_miss++;
        227.           return (NULL);
        228.       } else {

crypto/lhash/lhash.c:227:9: 
        225.       if (*rn == NULL) {
        226.           lh->num_retrieve_miss++;
        227. >         return (NULL);
        228.       } else {
        229.           ret = (*rn)->data;

crypto/lhash/lhash.c:233:1: return from a call to lh_retrieve
        231.       }
        232.       return (ret);
        233. > }
        234.   
        235.   static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

crypto/objects/obj_lcl.h:5:1: return from a call to lh_OBJ_NAME_retrieve
      3.   typedef struct name_funcs_st NAME_FUNCS;
      4.   DEFINE_STACK_OF(NAME_FUNCS)
      5. > DEFINE_LHASH_OF(OBJ_NAME);
      6.   typedef struct added_obj_st ADDED_OBJ;
      7.   DEFINE_LHASH_OF(ADDED_OBJ);

crypto/objects/o_names.c:151:13: Taking true branch
    149.       for (;;) {
    150.           ret = lh_OBJ_NAME_retrieve(names_lh, &on);
    151.           if (ret == NULL)
                       ^
    152.               return (NULL);
    153.           if ((ret->alias) && !alias) {

crypto/objects/o_names.c:152:13: 
    150.           ret = lh_OBJ_NAME_retrieve(names_lh, &on);
    151.           if (ret == NULL)
    152. >             return (NULL);
    153.           if ((ret->alias) && !alias) {
    154.               if (++num > 10)

crypto/objects/o_names.c:161:1: return from a call to OBJ_NAME_get
    159.           }
    160.       }
    161. > }
    162.   
    163.   int OBJ_NAME_add(const char *name, int type, const char *data)

crypto/evp/names.c:128:5: 
  126.   
  127.       cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
  128. >     return (cp);
  129.   }
  130.   

crypto/evp/names.c:129:1: return from a call to EVP_get_digestbyname
  127.       cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);
  128.       return (cp);
  129. > }
  130.   
  131.   void EVP_cleanup(void)

crypto/pkcs7/pk7_doit.c:113:9: Taking true branch
111.   
112.       md = EVP_get_digestbyobj(alg->algorithm);
113.       if (md == NULL) {
               ^
114.           PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE);
115.           goto err;

crypto/pkcs7/pk7_doit.c:114:9: Skipping ERR_put_error(): empty list of specs
112.       md = EVP_get_digestbyobj(alg->algorithm);
113.       if (md == NULL) {
114.           PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE);
               ^
115.           goto err;
116.       }

crypto/pkcs7/pk7_doit.c:129:2: 
127.       return 1;
128.   
129. >  err:
130.       BIO_free(btmp);
131.       return 0;

crypto/pkcs7/pk7_doit.c:130:5: 
128.   
129.    err:
130. >     BIO_free(btmp);
131.       return 0;
132.   

crypto/bio/bio_lib.c:105:1: start of procedure BIO_free()
  103.   }
  104.   
  105. > int BIO_free(BIO *a)
  106.   {
  107.       int i;

crypto/bio/bio_lib.c:109:9: Taking false branch
  107.       int i;
  108.   
  109.       if (a == NULL)
                 ^
  110.           return (0);
  111.   

crypto/bio/bio_lib.c:112:5: 
  110.           return (0);
  111.   
  112. >     i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);
  113.       REF_PRINT_COUNT("BIO", a);
  114.       if (i > 0)

crypto/lock.c:456:1: start of procedure CRYPTO_add_lock()
    454.   }
    455.   
    456. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    457.                       int line)
    458.   {

crypto/lock.c:459:5: 
    457.                       int line)
    458.   {
    459. >     int ret = 0;
    460.   
    461.       if (add_lock_callback != NULL) {

crypto/lock.c:461:9: Taking false branch
    459.       int ret = 0;
    460.   
    461.       if (add_lock_callback != NULL) {
                   ^
    462.   #ifdef LOCK_DEBUG
    463.           int before = *pointer;

crypto/lock.c:477:9: 
    475.   #endif
    476.       } else {
    477. >         CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    478.   
    479.           ret = *pointer + amount;

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking false branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:479:9: 
    477.           CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    478.   
    479. >         ret = *pointer + amount;
    480.   #ifdef LOCK_DEBUG
    481.           {

crypto/lock.c:490:9: 
    488.           }
    489.   #endif
    490. >         *pointer = ret;
    491.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }

crypto/lock.c:491:9: 
    489.   #endif
    490.           *pointer = ret;
    491. >         CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }
    493.       return (ret);

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking false branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:493:5: 
    491.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }
    493. >     return (ret);
    494.   }
    495.   

crypto/lock.c:494:1: return from a call to CRYPTO_add_lock
    492.       }
    493.       return (ret);
    494. > }
    495.   
    496.   const char *CRYPTO_get_lock_name(int type)

crypto/bio/bio_lib.c:114:9: Taking false branch
  112.       i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);
  113.       REF_PRINT_COUNT("BIO", a);
  114.       if (i > 0)
                 ^
  115.           return (1);
  116.       REF_ASSERT_ISNT(i < 0);

crypto/bio/bio_lib.c:117:10: Taking true branch
  115.           return (1);
  116.       REF_ASSERT_ISNT(i < 0);
  117.       if ((a->callback != NULL) &&
                  ^
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  119.           return (i);

crypto/bio/bio_lib.c:118:10: Taking true branch
  116.       REF_ASSERT_ISNT(i < 0);
  117.       if ((a->callback != NULL) &&
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
                  ^
  119.           return (i);
  120.   

crypto/bio/bio_lib.c:119:9: 
  117.       if ((a->callback != NULL) &&
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  119. >         return (i);
  120.   
  121.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);

crypto/bio/bio_lib.c:127:1: return from a call to BIO_free
  125.       OPENSSL_free(a);
  126.       return (1);
  127. > }
  128.   
  129.   void BIO_vfree(BIO *a)

static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)
{
    BIO *btmp;
    const EVP_MD *md;
    if ((btmp = BIO_new(BIO_f_md())) == NULL) {
        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);
        goto err;
    }
    md = EVP_get_digestbyobj(alg->algorithm);
    if (md == NULL) {
        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE);
        goto err;
    }
    BIO_set_md(btmp, md);
    if (*pbio == NULL)
        *pbio = btmp;
    else if (!BIO_push(*pbio, btmp)) {
        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);
        goto err;
    }
    btmp = NULL;
    return 1;
 err:
    BIO_free(btmp);
    return 0;
}
['static int PKCS7_bio_add_digest(BIO **pbio, X509_ALGOR *alg)\n{\n    BIO *btmp;\n    const EVP_MD *md;\n    if ((btmp = BIO_new(BIO_f_md())) == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);\n        goto err;\n    }\n    md = EVP_get_digestbyobj(alg->algorithm);\n    if (md == NULL) {\n        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, PKCS7_R_UNKNOWN_DIGEST_TYPE);\n        goto err;\n    }\n    BIO_set_md(btmp, md);\n    if (*pbio == NULL)\n        *pbio = btmp;\n    else if (!BIO_push(*pbio, btmp)) {\n        PKCS7err(PKCS7_F_PKCS7_BIO_ADD_DIGEST, ERR_R_BIO_LIB);\n        goto err;\n    }\n    btmp = NULL;\n    return 1;\n err:\n    BIO_free(btmp);\n    return 0;\n}', 'BIO_METHOD *BIO_f_md(void)\n{\n    return (&methods_md);\n}', 'BIO *BIO_new(BIO_METHOD *method)\n{\n    BIO *ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL) {\n        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    if (!BIO_set(ret, method)) {\n        OPENSSL_free(ret);\n        ret = NULL;\n    }\n    return (ret);\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\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    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'int OBJ_obj2nid(const ASN1_OBJECT *a)\n{\n    const unsigned int *op;\n    ADDED_OBJ ad, *adp;\n    if (a == NULL)\n        return (NID_undef);\n    if (a->nid != 0)\n        return (a->nid);\n    if (a->length == 0)\n        return NID_undef;\n    if (added != NULL) {\n        ad.type = ADDED_DATA;\n        ad.obj = (ASN1_OBJECT *)a;\n        adp = lh_ADDED_OBJ_retrieve(added, &ad);\n        if (adp != NULL)\n            return (adp->obj->nid);\n    }\n    op = OBJ_bsearch_obj(&a, obj_objs, NUM_OBJ);\n    if (op == NULL)\n        return (NID_undef);\n    return (nid_objs[*op].nid);\n}', 'const char *OBJ_nid2sn(int n)\n{\n    ADDED_OBJ ad, *adp;\n    ASN1_OBJECT ob;\n    if ((n >= 0) && (n < NUM_NID)) {\n        if ((n != NID_undef) && (nid_objs[n].nid == NID_undef)) {\n            OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n        return (nid_objs[n].sn);\n    } else if (added == NULL)\n        return (NULL);\n    else {\n        ad.type = ADDED_NID;\n        ad.obj = &ob;\n        ob.nid = n;\n        adp = lh_ADDED_OBJ_retrieve(added, &ad);\n        if (adp != NULL)\n            return (adp->obj->sn);\n        else {\n            OBJerr(OBJ_F_OBJ_NID2SN, OBJ_R_UNKNOWN_NID);\n            return (NULL);\n        }\n    }\n}', 'const EVP_MD *EVP_get_digestbyname(const char *name)\n{\n    const EVP_MD *cp;\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL))\n        return NULL;\n    cp = (const EVP_MD *)OBJ_NAME_get(name, OBJ_NAME_TYPE_MD_METH);\n    return (cp);\n}', 'const char *OBJ_NAME_get(const char *name, int type)\n{\n    OBJ_NAME on, *ret;\n    int num = 0, alias;\n    if (name == NULL)\n        return (NULL);\n    if ((names_lh == NULL) && !OBJ_NAME_init())\n        return (NULL);\n    alias = type & OBJ_NAME_ALIAS;\n    type &= ~OBJ_NAME_ALIAS;\n    on.name = name;\n    on.type = type;\n    for (;;) {\n        ret = lh_OBJ_NAME_retrieve(names_lh, &on);\n        if (ret == NULL)\n            return (NULL);\n        if ((ret->alias) && !alias) {\n            if (++num > 10)\n                return (NULL);\n            on.name = ret->data;\n        } else {\n            return (ret->data);\n        }\n    }\n}', 'void *lh_retrieve(_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    LHASH_NODE **rn;\n    void *ret;\n    lh->error = 0;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        lh->num_retrieve_miss++;\n        return (NULL);\n    } else {\n        ret = (*rn)->data;\n        lh->num_retrieve++;\n    }\n    return (ret);\n}', 'int BIO_free(BIO *a)\n{\n    int i;\n    if (a == NULL)\n        return (0);\n    i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);\n    REF_PRINT_COUNT("BIO", a);\n    if (i > 0)\n        return (1);\n    REF_ASSERT_ISNT(i < 0);\n    if ((a->callback != NULL) &&\n        ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))\n        return (i);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);\n    if ((a->method != NULL) && (a->method->destroy != NULL))\n        a->method->destroy(a);\n    OPENSSL_free(a);\n    return (1);\n}', 'int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line)\n{\n    int ret = 0;\n    if (add_lock_callback != NULL) {\n#ifdef LOCK_DEBUG\n        int before = *pointer;\n#endif\n        ret = add_lock_callback(pointer, amount, type, file, line);\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id), before, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n    } else {\n        CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);\n        ret = *pointer + amount;\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id),\n                    *pointer, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n        *pointer = ret;\n        CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);\n    }\n    return (ret);\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}']