Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
2ea09100
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
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看板
提交
2ea09100
编写于
5月 21, 2000
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid sprintf, and harmonize indentation.
上级
33399fde
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
76 addition
and
73 deletion
+76
-73
ssl/ssl_cert.c
ssl/ssl_cert.c
+76
-73
未找到文件。
ssl/ssl_cert.c
浏览文件 @
2ea09100
...
...
@@ -644,53 +644,53 @@ err:
int
SSL_add_file_cert_subjects_to_stack
(
STACK_OF
(
X509_NAME
)
*
stack
,
const
char
*
file
)
{
BIO
*
in
;
X509
*
x
=
NULL
;
X509_NAME
*
xn
=
NULL
;
int
ret
=
1
;
int
(
*
oldcmp
)(
X509_NAME
**
a
,
X509_NAME
**
b
);
oldcmp
=
sk_X509_NAME_set_cmp_func
(
stack
,
xname_cmp
);
in
=
BIO_new
(
BIO_s_file_internal
());
if
(
in
==
NULL
)
{
SSLerr
(
SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK
,
ERR_R_MALLOC_FAILURE
);
goto
err
;
}
BIO
*
in
;
X509
*
x
=
NULL
;
X509_NAME
*
xn
=
NULL
;
int
ret
=
1
;
int
(
*
oldcmp
)(
X509_NAME
**
a
,
X509_NAME
**
b
);
if
(
!
BIO_read_filename
(
in
,
file
))
goto
err
;
for
(;;)
{
if
(
PEM_read_bio_X509
(
in
,
&
x
,
NULL
,
NULL
)
==
NULL
)
break
;
if
((
xn
=
X509_get_subject_name
(
x
))
==
NULL
)
goto
err
;
xn
=
X509_NAME_dup
(
xn
);
if
(
xn
==
NULL
)
goto
err
;
if
(
sk_X509_NAME_find
(
stack
,
xn
)
>=
0
)
X509_NAME_free
(
xn
);
else
sk_X509_NAME_push
(
stack
,
xn
);
}
oldcmp
=
sk_X509_NAME_set_cmp_func
(
stack
,
xname_cmp
);
in
=
BIO_new
(
BIO_s_file_internal
());
if
(
in
==
NULL
)
{
SSLerr
(
SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK
,
ERR_R_MALLOC_FAILURE
);
goto
err
;
}
if
(
!
BIO_read_filename
(
in
,
file
))
goto
err
;
for
(;;)
{
if
(
PEM_read_bio_X509
(
in
,
&
x
,
NULL
,
NULL
)
==
NULL
)
break
;
if
((
xn
=
X509_get_subject_name
(
x
))
==
NULL
)
goto
err
;
xn
=
X509_NAME_dup
(
xn
);
if
(
xn
==
NULL
)
goto
err
;
if
(
sk_X509_NAME_find
(
stack
,
xn
)
>=
0
)
X509_NAME_free
(
xn
);
else
sk_X509_NAME_push
(
stack
,
xn
);
}
if
(
0
)
{
if
(
0
)
{
err:
ret
=
0
;
}
if
(
in
!=
NULL
)
BIO_free
(
in
);
if
(
x
!=
NULL
)
X509_free
(
x
);
sk_X509_NAME_set_cmp_func
(
stack
,
oldcmp
);
ret
=
0
;
}
if
(
in
!=
NULL
)
BIO_free
(
in
);
if
(
x
!=
NULL
)
X509_free
(
x
);
sk_X509_NAME_set_cmp_func
(
stack
,
oldcmp
);
return
ret
;
}
return
ret
;
}
/*!
* Add a directory of certs to a stack.
...
...
@@ -709,43 +709,46 @@ err:
int
SSL_add_dir_cert_subjects_to_stack
(
STACK_OF
(
X509_NAME
)
*
stack
,
const
char
*
dir
)
{
DIR
*
d
;
struct
dirent
*
dstruct
;
int
ret
=
0
;
CRYPTO_w_lock
(
CRYPTO_LOCK_READDIR
);
d
=
opendir
(
dir
);
/* Note that a side effect is that the CAs will be sorted by name */
if
(
!
d
)
{
SYSerr
(
SYS_F_OPENDIR
,
get_last_sys_error
());
ERR_add_error_data
(
3
,
"opendir('"
,
dir
,
"')"
);
SSLerr
(
SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK
,
ERR_R_SYS_LIB
);
goto
err
;
}
DIR
*
d
;
struct
dirent
*
dstruct
;
int
ret
=
0
;
while
((
dstruct
=
readdir
(
d
)))
{
char
buf
[
1024
];
CRYPTO_w_lock
(
CRYPTO_LOCK_READDIR
);
d
=
opendir
(
dir
);
if
(
strlen
(
dir
)
+
strlen
(
dstruct
->
d_name
)
+
2
>
sizeof
buf
)
{
SSLerr
(
SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK
,
SSL_R_PATH_TOO_LONG
);
goto
err
;
}
/* Note that a side effect is that the CAs will be sorted by name */
if
(
!
d
)
{
SYSerr
(
SYS_F_OPENDIR
,
get_last_sys_error
());
ERR_add_error_data
(
3
,
"opendir('"
,
dir
,
"')"
);
SSLerr
(
SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK
,
ERR_R_SYS_LIB
);
goto
err
;
}
sprintf
(
buf
,
"%s/%s"
,
dir
,
dstruct
->
d_name
);
if
(
!
SSL_add_file_cert_subjects_to_stack
(
stack
,
buf
))
goto
err
;
}
ret
=
1
;
while
((
dstruct
=
readdir
(
d
)))
{
char
buf
[
1024
];
int
r
;
if
(
strlen
(
dir
)
+
strlen
(
dstruct
->
d_name
)
+
2
>
sizeof
buf
)
{
SSLerr
(
SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK
,
SSL_R_PATH_TOO_LONG
);
goto
err
;
}
r
=
BIO_snprintf
(
buf
,
sizeof
buf
,
"%s/%s"
,
dir
,
dstruct
->
d_name
);
if
(
r
<=
0
||
r
>=
sizeof
buf
)
goto
err
;
if
(
!
SSL_add_file_cert_subjects_to_stack
(
stack
,
buf
))
goto
err
;
}
ret
=
1
;
err:
CRYPTO_w_unlock
(
CRYPTO_LOCK_READDIR
);
return
ret
;
}
CRYPTO_w_unlock
(
CRYPTO_LOCK_READDIR
);
return
ret
;
}
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录