Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
f21cee02
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f21cee02
编写于
7月 14, 2020
作者:
Z
zhongjiafeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
strcmp -> strncmp
上级
9fbd87dc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
2 deletion
+4
-2
deploy/encryption/src/util/system_utils.cpp
deploy/encryption/src/util/system_utils.cpp
+4
-2
未找到文件。
deploy/encryption/src/util/system_utils.cpp
浏览文件 @
f21cee02
...
@@ -41,13 +41,14 @@ int SystemUtils::check_key_match(const char* key, const char* filepath) {
...
@@ -41,13 +41,14 @@ int SystemUtils::check_key_match(const char* key, const char* filepath) {
int
ret
=
int
ret
=
ioutil
::
read_with_pos_and_length
(
filepath
,
data_pos
,
constant
::
MAGIC_NUMBER_LEN
+
constant
::
VERSION_LEN
,
64
);
ioutil
::
read_with_pos_and_length
(
filepath
,
data_pos
,
constant
::
MAGIC_NUMBER_LEN
+
constant
::
VERSION_LEN
,
64
);
if
(
ret
!=
CODE_OK
)
{
if
(
ret
!=
CODE_OK
)
{
free
(
data_pos
);
LOGD
(
"[M]read file failed when check key"
);
LOGD
(
"[M]read file failed when check key"
);
return
ret
;
return
ret
;
}
}
std
::
string
check_str
((
char
*
)
data_pos
,
64
);
std
::
string
check_str
((
char
*
)
data_pos
,
64
);
free
(
data_pos
);
free
(
data_pos
);
if
(
str
cmp
(
sha256_aes_key_iv
.
c_str
(),
check_str
.
c_str
()
)
!=
0
)
{
if
(
str
ncmp
(
sha256_aes_key_iv
.
c_str
(),
check_str
.
c_str
(),
64
)
!=
0
)
{
return
CODE_KEY_NOT_MATCH
;
return
CODE_KEY_NOT_MATCH
;
}
}
return
CODE_OK
;
return
CODE_OK
;
...
@@ -62,13 +63,14 @@ int SystemUtils::check_file_encrypted(const char* filepath) {
...
@@ -62,13 +63,14 @@ int SystemUtils::check_file_encrypted(const char* filepath) {
size_t
read_len
=
constant
::
MAGIC_NUMBER_LEN
+
constant
::
VERSION_LEN
;
size_t
read_len
=
constant
::
MAGIC_NUMBER_LEN
+
constant
::
VERSION_LEN
;
unsigned
char
*
data_pos
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
read_len
);
unsigned
char
*
data_pos
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
read_len
);
if
(
ioutil
::
read_with_pos_and_length
(
filepath
,
data_pos
,
0
,
read_len
)
!=
CODE_OK
)
{
if
(
ioutil
::
read_with_pos_and_length
(
filepath
,
data_pos
,
0
,
read_len
)
!=
CODE_OK
)
{
free
(
data_pos
);
LOGD
(
"check file failed when read %s(file)"
,
filepath
);
LOGD
(
"check file failed when read %s(file)"
,
filepath
);
return
CODE_OPEN_FAILED
;
return
CODE_OPEN_FAILED
;
}
}
std
::
string
tag
(
constant
::
MAGIC_NUMBER
);
std
::
string
tag
(
constant
::
MAGIC_NUMBER
);
tag
.
append
(
constant
::
VERSION
);
tag
.
append
(
constant
::
VERSION
);
int
ret_cmp
=
str
cmp
(
tag
.
c_str
(),
(
const
char
*
)
data_pos
)
==
0
?
0
:
1
;
int
ret_cmp
=
str
ncmp
(
tag
.
c_str
(),
(
const
char
*
)
data_pos
,
read_len
)
==
0
?
0
:
1
;
free
(
data_pos
);
free
(
data_pos
);
return
ret_cmp
;
return
ret_cmp
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录