Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
daba492c
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
大约 1 年 前同步成功
通知
9
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,发现更多精彩内容 >>
提交
daba492c
编写于
7月 25, 2001
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
md_rand.c thread safety
上级
24cff6ce
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
18 deletion
+45
-18
CHANGES
CHANGES
+8
-2
crypto/cryptlib.c
crypto/cryptlib.c
+2
-1
crypto/crypto.h
crypto/crypto.h
+14
-13
crypto/rand/md_rand.c
crypto/rand/md_rand.c
+21
-2
未找到文件。
CHANGES
浏览文件 @
daba492c
...
...
@@ -8,8 +8,8 @@
and OpenSSL 0.9.7 were developped in parallel, based on OpenSSL 0.9.6.
Change log entries are tagged as follows:
-) applies to 0.9.6a/0.9.6b only
*) applies to 0.9.6a/0.9.6b and 0.9.7
-) applies to 0.9.6a/0.9.6b
/0.9.6c
only
*) applies to 0.9.6a/0.9.6b
/0.9.6c
and 0.9.7
+) applies to 0.9.7 only
*) In
...
...
@@ -24,6 +24,12 @@
always reject numbers >= n.
[Bodo Moeller]
*) In crypto/rand/md_rand.c, use a new short-time lock CRYPTO_LOCK_RAND2
to synchronize access to 'locking_thread'. This is necessary on
systems where access to 'locking_thread' (an 'unsigned long'
variable) is not atomic.
[Bodo Moeller]
*) In crypto/rand/md_rand.c, set 'locking_thread' to current thread's ID
*before* setting the 'crypto_lock_rand' flag. The previous code had
a race condition if 0 is a valid thread ID.
...
...
crypto/cryptlib.c
浏览文件 @
daba492c
...
...
@@ -90,6 +90,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
"ssl_sess_cert"
,
"ssl"
,
"rand"
,
"rand2"
,
"debug_malloc"
,
"BIO"
,
"gethostbyname"
,
...
...
@@ -102,7 +103,7 @@ static const char* lock_names[CRYPTO_NUM_LOCKS] =
"dynlock"
,
"engine"
,
"ui"
,
#if CRYPTO_NUM_LOCKS != 3
0
#if CRYPTO_NUM_LOCKS != 3
1
# error "Inconsistency between crypto.h and cryptlib.c"
#endif
};
...
...
crypto/crypto.h
浏览文件 @
daba492c
...
...
@@ -113,19 +113,20 @@ extern "C" {
#define CRYPTO_LOCK_SSL_SESS_CERT 15
#define CRYPTO_LOCK_SSL 16
#define CRYPTO_LOCK_RAND 17
#define CRYPTO_LOCK_MALLOC 18
#define CRYPTO_LOCK_BIO 19
#define CRYPTO_LOCK_GETHOSTBYNAME 20
#define CRYPTO_LOCK_GETSERVBYNAME 21
#define CRYPTO_LOCK_READDIR 22
#define CRYPTO_LOCK_RSA_BLINDING 23
#define CRYPTO_LOCK_DH 24
#define CRYPTO_LOCK_MALLOC2 25
#define CRYPTO_LOCK_DSO 26
#define CRYPTO_LOCK_DYNLOCK 27
#define CRYPTO_LOCK_ENGINE 28
#define CRYPTO_LOCK_UI 29
#define CRYPTO_NUM_LOCKS 30
#define CRYPTO_LOCK_RAND2 18
#define CRYPTO_LOCK_MALLOC 19
#define CRYPTO_LOCK_BIO 20
#define CRYPTO_LOCK_GETHOSTBYNAME 21
#define CRYPTO_LOCK_GETSERVBYNAME 22
#define CRYPTO_LOCK_READDIR 23
#define CRYPTO_LOCK_RSA_BLINDING 24
#define CRYPTO_LOCK_DH 25
#define CRYPTO_LOCK_MALLOC2 26
#define CRYPTO_LOCK_DSO 27
#define CRYPTO_LOCK_DYNLOCK 28
#define CRYPTO_LOCK_ENGINE 29
#define CRYPTO_LOCK_UI 30
#define CRYPTO_NUM_LOCKS 31
#define CRYPTO_LOCK 1
#define CRYPTO_UNLOCK 2
...
...
crypto/rand/md_rand.c
浏览文件 @
daba492c
...
...
@@ -144,6 +144,7 @@ static int initialized=0;
static
unsigned
int
crypto_lock_rand
=
0
;
/* may be set only when a thread
* holds CRYPTO_LOCK_RAND
* (to prevent double locking) */
/* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
static
unsigned
long
locking_thread
=
0
;
/* valid iff crypto_lock_rand is set */
...
...
@@ -210,7 +211,14 @@ static void ssleay_rand_add(const void *buf, int num, double add)
*/
/* check if we already have the lock */
do_not_lock
=
crypto_lock_rand
&&
(
locking_thread
==
CRYPTO_thread_id
());
if
(
crypto_lock_rand
)
{
CRYPTO_r_lock
(
CRYPTO_LOCK_RAND2
);
do_not_lock
=
(
locking_thread
==
CRYPTO_thread_id
());
CRYPTO_r_unlock
(
CRYPTO_LOCK_RAND2
);
}
else
do_not_lock
=
0
;
if
(
!
do_not_lock
)
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND
);
st_idx
=
state_index
;
...
...
@@ -361,7 +369,9 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND
);
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND2
);
locking_thread
=
CRYPTO_thread_id
();
CRYPTO_w_unlock
(
CRYPTO_LOCK_RAND2
);
crypto_lock_rand
=
1
;
if
(
!
initialized
)
...
...
@@ -520,14 +530,23 @@ static int ssleay_rand_status(void)
/* check if we already have the lock
* (could happen if a RAND_poll() implementation calls RAND_status()) */
do_not_lock
=
crypto_lock_rand
&&
(
locking_thread
==
CRYPTO_thread_id
());
if
(
crypto_lock_rand
)
{
CRYPTO_r_lock
(
CRYPTO_LOCK_RAND2
);
do_not_lock
=
(
locking_thread
==
CRYPTO_thread_id
());
CRYPTO_r_unlock
(
CRYPTO_LOCK_RAND2
);
}
else
do_not_lock
=
0
;
if
(
!
do_not_lock
)
{
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND
);
/* prevent ssleay_rand_bytes() from trying to obtain the lock again */
CRYPTO_w_lock
(
CRYPTO_LOCK_RAND2
);
locking_thread
=
CRYPTO_thread_id
();
CRYPTO_w_unlock
(
CRYPTO_LOCK_RAND2
);
crypto_lock_rand
=
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录