Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
dcba2534
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
8 个月 前同步成功
通知
8
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dcba2534
编写于
4月 29, 2000
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid leaking memory in thread_hash (and enable memory leak detection
for it).
上级
b222eb64
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
26 deletion
+42
-26
CHANGES
CHANGES
+6
-0
crypto/err/err.c
crypto/err/err.c
+32
-20
crypto/err/err.h
crypto/err/err.h
+4
-6
未找到文件。
CHANGES
浏览文件 @
dcba2534
...
...
@@ -4,6 +4,12 @@
Changes between 0.9.5a and 0.9.6 [xx XXX 2000]
*) Avoid 'thread_hash' memory leak in crypto/err/err.c by freeing
it in ERR_remove_state if appropriate, and change ERR_get_state
accordingly to avoid race conditions (this is necessary because
thread_hash is no longer constant once set).
[Bodo Moeller]
*) Bugfix for linux-elf makefile.one.
[Ulf Möller]
...
...
crypto/err/err.c
浏览文件 @
dcba2534
...
...
@@ -116,9 +116,8 @@
#include <openssl/crypto.h>
#include "cryptlib.h"
#include <openssl/buffer.h>
#include <openssl/err.h>
#include <openssl/crypto.h>
#include <openssl/bio.h>
#include <openssl/err.h>
static
LHASH
*
error_hash
=
NULL
;
...
...
@@ -545,6 +544,7 @@ LHASH *ERR_get_string_table(void)
return
(
error_hash
);
}
/* not thread-safe */
LHASH
*
ERR_get_err_state_table
(
void
)
{
return
(
thread_hash
);
...
...
@@ -652,6 +652,12 @@ void ERR_remove_state(unsigned long pid)
tmp
.
pid
=
pid
;
CRYPTO_w_lock
(
CRYPTO_LOCK_ERR
);
p
=
(
ERR_STATE
*
)
lh_delete
(
thread_hash
,
&
tmp
);
if
(
lh_num_items
(
thread_hash
)
==
0
)
{
/* make sure we don't leak memory */
lh_free
(
thread_hash
);
thread_hash
=
NULL
;
}
CRYPTO_w_unlock
(
CRYPTO_LOCK_ERR
);
if
(
p
!=
NULL
)
ERR_STATE_free
(
p
);
...
...
@@ -661,33 +667,19 @@ ERR_STATE *ERR_get_state(void)
{
static
ERR_STATE
fallback
;
ERR_STATE
*
ret
=
NULL
,
tmp
,
*
tmpp
;
int
thread_state_exists
;
int
i
;
unsigned
long
pid
;
pid
=
(
unsigned
long
)
CRYPTO_thread_id
();
CRYPTO_r_lock
(
CRYPTO_LOCK_ERR
);
if
(
thread_hash
==
NULL
)
{
CRYPTO_r_unlock
(
CRYPTO_LOCK_ERR
);
CRYPTO_w_lock
(
CRYPTO_LOCK_ERR
);
if
(
thread_hash
==
NULL
)
{
MemCheck_off
();
thread_hash
=
lh_new
(
pid_hash
,
pid_cmp
);
MemCheck_on
();
CRYPTO_w_unlock
(
CRYPTO_LOCK_ERR
);
if
(
thread_hash
==
NULL
)
return
(
&
fallback
);
}
else
CRYPTO_w_unlock
(
CRYPTO_LOCK_ERR
);
}
else
if
(
thread_hash
!=
NULL
)
{
tmp
.
pid
=
pid
;
ret
=
(
ERR_STATE
*
)
lh_retrieve
(
thread_hash
,
&
tmp
);
CRYPTO_r_unlock
(
CRYPTO_LOCK_ERR
);
}
CRYPTO_r_unlock
(
CRYPTO_LOCK_ERR
);
/* ret == the error state, if NULL, make a new one */
if
(
ret
==
NULL
)
...
...
@@ -702,9 +694,29 @@ ERR_STATE *ERR_get_state(void)
ret
->
err_data
[
i
]
=
NULL
;
ret
->
err_data_flags
[
i
]
=
0
;
}
CRYPTO_w_lock
(
CRYPTO_LOCK_ERR
);
tmpp
=
(
ERR_STATE
*
)
lh_insert
(
thread_hash
,
ret
);
/* no entry yet in thread_hash for current thread -
* thus, it may have changed since we last looked at it */
if
(
thread_hash
==
NULL
)
thread_hash
=
lh_new
(
pid_hash
,
pid_cmp
);
if
(
thread_hash
==
NULL
)
thread_state_exists
=
0
;
/* allocation error */
else
{
tmpp
=
(
ERR_STATE
*
)
lh_insert
(
thread_hash
,
ret
);
thread_state_exists
=
1
;
}
CRYPTO_w_unlock
(
CRYPTO_LOCK_ERR
);
if
(
!
thread_state_exists
)
{
ERR_STATE_free
(
ret
);
/* could not insert it */
return
(
&
fallback
);
}
if
(
tmpp
!=
NULL
)
/* old entry - should not happen */
{
ERR_STATE_free
(
tmpp
);
...
...
crypto/err/err.h
浏览文件 @
dcba2534
...
...
@@ -253,14 +253,12 @@ void ERR_remove_state(unsigned long pid); /* if zero we look it up */
ERR_STATE
*
ERR_get_state
(
void
);
#ifdef HEADER_LHASH_H
LHASH
*
ERR_get_string_table
(
void
);
LHASH
*
ERR_get_err_state_table
(
void
);
#else
char
*
ERR_get_string_table
(
void
);
char
*
ERR_get_err_state_table
(
void
);
LHASH
*
ERR_get_string_table
(
void
);
LHASH
*
ERR_get_err_state_table
(
void
);
/* even less thread-safe than
* ERR_get_string_table :-) */
#endif
int
ERR_get_next_error_library
(
void
);
int
ERR_get_next_error_library
(
void
);
#ifdef __cplusplus
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录