提交 4fae386c 编写于 作者: R Rich Salz 提交者: Rich Salz

Cleanup CRYPTO_{push,pop}_info

Rename to OPENSSL_mem_debug_{push,pop}.
Remove simple calls; keep only calls used in recursive functions.
Ensure we always push, to simplify so that we can always pop
Reviewed-by: NRichard Levitte <levitte@openssl.org>
上级 c99de053
......@@ -103,8 +103,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
asn1_cb = 0;
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_push_info(it->sname);
OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new");
#endif
switch (it->itype) {
......@@ -137,8 +136,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
goto auxerr;
if (i == 2) {
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return 1;
}
......@@ -163,8 +161,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
goto auxerr;
if (i == 2) {
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return 1;
}
......@@ -188,16 +185,14 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
break;
}
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return 1;
memerr:
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE);
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return 0;
......@@ -205,8 +200,7 @@ int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed)
ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR);
ASN1_item_ex_free(pval, it);
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return 0;
......@@ -266,8 +260,8 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
return 1;
}
#ifdef CRYPTO_MDEBUG
if (tt->field_name)
CRYPTO_push_info(tt->field_name);
OPENSSL_mem_debug_push(tt->field_name
? tt->field_name : "asn1_template_new");
#endif
/* If SET OF or SEQUENCE OF, its a STACK */
if (tt->flags & ASN1_TFLG_SK_MASK) {
......@@ -286,8 +280,7 @@ static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
ret = asn1_item_embed_new(pval, it, embed);
done:
#ifdef CRYPTO_MDEBUG
if (it->sname)
CRYPTO_pop_info();
OPENSSL_mem_debug_pop();
#endif
return ret;
}
......
......@@ -767,7 +767,6 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args)
int ignored;
dynbuf = NULL;
CRYPTO_push_info("doapr()");
_dopr(&hugebufp, &dynbuf, &hugebufsize, &retlen, &ignored, format, args);
if (dynbuf) {
ret = BIO_write(bio, dynbuf, (int)retlen);
......@@ -775,7 +774,6 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args)
} else {
ret = BIO_write(bio, hugebuf, (int)retlen);
}
CRYPTO_pop_info();
return (ret);
}
......
......@@ -276,9 +276,7 @@ static LHASH_OF(ERR_STRING_DATA) *get_hash(int create, int lockit)
if (lockit)
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
if (!int_error_hash && create) {
CRYPTO_push_info("get_hash (err.c)");
int_error_hash = lh_ERR_STRING_DATA_new();
CRYPTO_pop_info();
}
if (int_error_hash != NULL)
ret = int_error_hash;
......@@ -323,9 +321,7 @@ static LHASH_OF(ERR_STATE) *int_thread_get(int create, int lockit)
if (lockit)
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
if (!int_thread_hash && create) {
CRYPTO_push_info("int_thread_get (err.c)");
int_thread_hash = lh_ERR_STATE_new();
CRYPTO_pop_info();
}
if (int_thread_hash != NULL) {
int_thread_hash_references++;
......
......@@ -145,9 +145,8 @@ typedef struct app_mem_info_st
* For application-defined information (static C-string `info')
* to be displayed in memory leak list.
* Each thread has its own stack. For applications, there is
* CRYPTO_push_info("...") to push an entry,
* CRYPTO_pop_info() to pop an entry,
* CRYPTO_remove_all_info() to pop all entries.
* OPENSSL_mem_debug_push("...") to push an entry,
* OPENSSL_mem_debug_pop() to pop an entry,
*/
{
CRYPTO_THREADID threadid;
......@@ -384,7 +383,7 @@ static APP_INFO *pop_info(void)
return (ret);
}
int CRYPTO_push_info_(const char *info, const char *file, int line)
int CRYPTO_mem_debug_push(const char *info, const char *file, int line)
{
APP_INFO *ami, *amim;
int ret = 0;
......@@ -420,7 +419,7 @@ int CRYPTO_push_info_(const char *info, const char *file, int line)
return (ret);
}
int CRYPTO_pop_info(void)
int CRYPTO_mem_debug_pop(void)
{
int ret = 0;
......@@ -435,21 +434,6 @@ int CRYPTO_pop_info(void)
return (ret);
}
int CRYPTO_remove_all_info(void)
{
int ret = 0;
if (is_MemCheck_on()) { /* _must_ be true */
MemCheck_off(); /* obtain MALLOC2 lock */
while (pop_info() != NULL)
ret++;
MemCheck_on(); /* release MALLOC2 lock */
}
return (ret);
}
static unsigned long break_order_num = 0;
void CRYPTO_dbg_malloc(void *addr, size_t num, const char *file, int line,
int before_p)
......
......@@ -507,11 +507,12 @@ void OPENSSL_cleanse(void *ptr, size_t len);
void CRYPTO_set_mem_debug_options(long bits);
long CRYPTO_get_mem_debug_options(void);
# define CRYPTO_push_info(info) \
CRYPTO_push_info_(info, __FILE__, __LINE__);
int CRYPTO_push_info_(const char *info, const char *file, int line);
int CRYPTO_pop_info(void);
int CRYPTO_remove_all_info(void);
# define OPENSSL_mem_debug_push(info) \
CRYPTO_mem_debug_push(info, __FILE__, __LINE__)
# define OPENSSL_mem_debug_pop() \
CRYPTO_mem_debug_pop()
int CRYPTO_mem_debug_push(const char *info, const char *file, int line);
int CRYPTO_mem_debug_pop(void);
/*
* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
......
......@@ -1680,12 +1680,12 @@ PKCS7_get_smimecap 2154 1_1_0 EXIST::FUNCTION:
PKCS7_sign 2155 1_1_0 EXIST::FUNCTION:
PKCS7_add_attrib_smimecap 2156 1_1_0 EXIST::FUNCTION:
CRYPTO_dbg_set_options 2157 1_1_0 EXIST::FUNCTION:
CRYPTO_remove_all_info 2158 1_1_0 EXIST::FUNCTION:
CRYPTO_remove_all_info 2158 1_1_0 NOEXIST::FUNCTION:
CRYPTO_get_mem_debug_functions 2159 1_1_0 EXIST::FUNCTION:
CRYPTO_is_mem_check_on 2160 1_1_0 EXIST::FUNCTION:
CRYPTO_set_mem_debug_functions 2161 1_1_0 EXIST::FUNCTION:
CRYPTO_pop_info 2162 1_1_0 EXIST::FUNCTION:
CRYPTO_push_info_ 2163 1_1_0 EXIST::FUNCTION:
CRYPTO_mem_debug_pop 2162 1_1_0 EXIST::FUNCTION:
CRYPTO_mem_debug_push 2163 1_1_0 EXIST::FUNCTION:
CRYPTO_set_mem_debug_options 2164 1_1_0 EXIST::FUNCTION:
PEM_write_PKCS8PrivateKey_nid 2165 1_1_0 EXIST::FUNCTION:STDIO
PEM_write_bio_PKCS8PrivateKey_nid 2166 1_1_0 EXIST:!VMS:FUNCTION:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册