Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
M
mbedtls
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
Container registry
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
esp-mirror
Mbed-TLS
mbedtls
提交
d23f5937
提交
d23f5937
编辑于
9 years ago
作者:
Manuel Pégourié-Gonnard
浏览文件
操作
下载
补丁
差异文件
Avoid static buffer in debug module
Caused issues in threading situations
上级
96fb685e
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
include/mbedtls/debug.h
+4
-1
4 个添加, 1 个删除
include/mbedtls/debug.h
library/debug.c
+26
-9
26 个添加, 9 个删除
library/debug.c
tests/suites/test_suite_debug.function
+1
-1
1 个添加, 1 个删除
tests/suites/test_suite_debug.function
有
31 个添加
和
11 个删除
include/mbedtls/debug.h
+
4
−
1
浏览文件 @
d23f5937
...
...
@@ -57,7 +57,7 @@
#define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, mbedtls_debug_fmt args )
mbedtls_debug_print_msg
_free
( ssl, level, __FILE__, __LINE__, mbedtls_debug_fmt args )
#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
...
...
@@ -118,6 +118,9 @@ char *mbedtls_debug_fmt( const char *format, ... );
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
text
);
void
mbedtls_debug_print_msg_free
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
char
*
text
);
void
mbedtls_debug_print_ret
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
text
,
int
ret
);
...
...
此差异已折叠。
点击以展开。
library/debug.c
+
26
−
9
浏览文件 @
d23f5937
...
...
@@ -37,9 +37,14 @@
#if defined(MBEDTLS_PLATFORM_C)
#include
"mbedtls/platform.h"
#else
#define mbedtls_snprintf snprintf
#include
<stdlib.h>
#define mbedtls_calloc calloc
#define mbedtls_free free
#define mbedtls_snprintf snprintf
#endif
#define DEBUG_BUF_SIZE 512
static
int
debug_log_mode
=
MBEDTLS_DEBUG_DFL_MODE
;
static
int
debug_threshold
=
0
;
...
...
@@ -56,23 +61,35 @@ void mbedtls_debug_set_threshold( int threshold )
char
*
mbedtls_debug_fmt
(
const
char
*
format
,
...
)
{
va_list
argp
;
static
char
str
[
512
];
char
*
str
=
mbedtls_calloc
(
DEBUG_BUF_SIZE
,
1
);
if
(
str
==
NULL
)
return
(
NULL
);
va_start
(
argp
,
format
);
#if defined(_WIN32)
_vsnprintf_s
(
str
,
sizeof
(
str
)
,
_TRUNCATE
,
format
,
argp
);
_vsnprintf_s
(
str
,
DEBUG_BUF_SIZE
,
_TRUNCATE
,
format
,
argp
);
#else
vsnprintf
(
str
,
sizeof
(
str
)
,
format
,
argp
);
vsnprintf
(
str
,
DEBUG_BUF_SIZE
,
format
,
argp
);
#endif
va_end
(
argp
);
return
(
str
);
}
void
mbedtls_debug_print_msg_free
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
char
*
text
)
{
if
(
text
!=
NULL
)
mbedtls_debug_print_msg
(
ssl
,
level
,
file
,
line
,
text
);
mbedtls_free
(
text
);
}
void
mbedtls_debug_print_msg
(
const
mbedtls_ssl_context
*
ssl
,
int
level
,
const
char
*
file
,
int
line
,
const
char
*
text
)
{
char
str
[
512
];
char
str
[
DEBUG_BUF_SIZE
];
if
(
ssl
->
conf
==
NULL
||
ssl
->
conf
->
f_dbg
==
NULL
||
level
>
debug_threshold
)
return
;
...
...
@@ -91,7 +108,7 @@ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
const
char
*
file
,
int
line
,
const
char
*
text
,
int
ret
)
{
char
str
[
512
];
char
str
[
DEBUG_BUF_SIZE
];
size_t
idx
=
0
;
if
(
ssl
->
conf
==
NULL
||
ssl
->
conf
->
f_dbg
==
NULL
||
level
>
debug_threshold
)
...
...
@@ -118,7 +135,7 @@ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
const
char
*
file
,
int
line
,
const
char
*
text
,
const
unsigned
char
*
buf
,
size_t
len
)
{
char
str
[
512
];
char
str
[
DEBUG_BUF_SIZE
];
char
txt
[
17
];
size_t
i
,
idx
=
0
;
...
...
@@ -179,7 +196,7 @@ void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
const
char
*
file
,
int
line
,
const
char
*
text
,
const
mbedtls_ecp_point
*
X
)
{
char
str
[
512
];
char
str
[
DEBUG_BUF_SIZE
];
if
(
ssl
->
conf
==
NULL
||
ssl
->
conf
->
f_dbg
==
NULL
||
level
>
debug_threshold
)
return
;
...
...
@@ -197,7 +214,7 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
const
char
*
file
,
int
line
,
const
char
*
text
,
const
mbedtls_mpi
*
X
)
{
char
str
[
512
];
char
str
[
DEBUG_BUF_SIZE
];
int
j
,
k
,
zeros
=
1
;
size_t
i
,
n
,
idx
=
0
;
...
...
此差异已折叠。
点击以展开。
tests/suites/test_suite_debug.function
+
1
−
1
浏览文件 @
d23f5937
...
...
@@ -48,7 +48,7 @@ void debug_print_msg_threshold( int threshold, int level, char *file, int line,
mbedtls_debug_set_threshold( threshold );
mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer);
mbedtls_debug_print_msg( &ssl, level, file, line,
mbedtls_debug_print_msg
_free
( &ssl, level, file, line,
mbedtls_debug_fmt("Text message, 2 == %d", 2 ) );
TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 );
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录