Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
67202973
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看板
提交
67202973
编写于
10月 01, 2015
作者:
E
Emilia Kasper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add PACKET_copy_all
Reviewed-by:
N
Matt Caswell
<
matt@openssl.org
>
上级
bf0fc412
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
16 deletion
+47
-16
ssl/packet_locl.h
ssl/packet_locl.h
+19
-1
ssl/s3_srvr.c
ssl/s3_srvr.c
+0
-9
ssl/ssl_sess.c
ssl/ssl_sess.c
+7
-4
test/packettest.c
test/packettest.c
+21
-2
未找到文件。
ssl/packet_locl.h
浏览文件 @
67202973
...
...
@@ -301,7 +301,7 @@ __owur static inline int PACKET_get_4(PACKET *pkt, unsigned long *data)
* underlying buffer gets freed
*/
__owur
static
inline
int
PACKET_peek_bytes
(
const
PACKET
*
pkt
,
unsigned
char
**
data
,
size_t
len
)
size_t
len
)
{
if
(
PACKET_remaining
(
pkt
)
<
len
)
return
0
;
...
...
@@ -355,6 +355,24 @@ __owur static inline int PACKET_copy_bytes(PACKET *pkt, unsigned char *data,
return
1
;
}
/*
* Copy packet data to |dest|, and set |len| to the number of copied bytes.
* If the packet has more than |dest_len| bytes, nothing is copied.
* Returns 1 if the packet data fits in |dest_len| bytes, 0 otherwise.
* Does not forward PACKET position (because it is typically the last thing
* done with a given PACKET).
*/
__owur
static
inline
int
PACKET_copy_all
(
const
PACKET
*
pkt
,
unsigned
char
*
dest
,
size_t
dest_len
,
size_t
*
len
)
{
if
(
PACKET_remaining
(
pkt
)
>
dest_len
)
{
*
len
=
0
;
return
0
;
}
*
len
=
pkt
->
remaining
;
memcpy
(
dest
,
pkt
->
curr
,
pkt
->
remaining
);
return
1
;
}
/*
* Copy |pkt| bytes to a newly allocated buffer and store a pointer to the
* result in |*data|, and the length in |len|.
...
...
ssl/s3_srvr.c
浏览文件 @
67202973
...
...
@@ -3457,15 +3457,6 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,
/* 3 = SSLV2_CIPHER_LEN > TLS_CIPHER_LEN = 2. */
unsigned
char
cipher
[
SSLV2_CIPHER_LEN
];
/*
* Can this ever happen?
* This method used to check for s->s3, but did so inconsistently.
*/
if
(
s
->
s3
==
NULL
)
{
*
al
=
SSL_AD_INTERNAL_ERROR
;
return
NULL
;
}
s
->
s3
->
send_connection_binding
=
0
;
n
=
sslv2format
?
SSLV2_CIPHER_LEN
:
TLS_CIPHER_LEN
;
...
...
ssl/ssl_sess.c
浏览文件 @
67202973
...
...
@@ -564,11 +564,14 @@ int ssl_get_prev_session(SSL *s, const PACKET *ext, const PACKET *session_id)
!
(
s
->
session_ctx
->
session_cache_mode
&
SSL_SESS_CACHE_NO_INTERNAL_LOOKUP
))
{
SSL_SESSION
data
;
size_t
local_len
;
data
.
ssl_version
=
s
->
version
;
data
.
session_id_length
=
len
;
if
(
len
==
0
)
return
0
;
memcpy
(
data
.
session_id
,
PACKET_data
(
session_id
),
len
);
if
(
!
PACKET_copy_all
(
session_id
,
data
.
session_id
,
sizeof
(
data
.
session_id
),
&
local_len
))
{
goto
err
;
}
data
.
session_id_length
=
local_len
;
CRYPTO_r_lock
(
CRYPTO_LOCK_SSL_CTX
);
ret
=
lh_SSL_SESSION_retrieve
(
s
->
session_ctx
->
sessions
,
&
data
);
if
(
ret
!=
NULL
)
{
...
...
test/packettest.c
浏览文件 @
67202973
...
...
@@ -240,6 +240,25 @@ static int test_PACKET_copy_bytes(unsigned char buf[BUF_LEN])
return
1
;
}
static
int
test_PACKET_copy_all
(
unsigned
char
buf
[
BUF_LEN
])
{
unsigned
char
dup
[
BUF_LEN
];
PACKET
pkt
;
size_t
len
;
if
(
!
PACKET_buf_init
(
&
pkt
,
buf
,
BUF_LEN
)
||
!
PACKET_copy_all
(
&
pkt
,
dup
,
BUF_LEN
,
&
len
)
||
len
!=
BUF_LEN
||
memcmp
(
buf
,
dup
,
BUF_LEN
)
!=
0
||
PACKET_remaining
(
&
pkt
)
!=
BUF_LEN
||
PACKET_copy_all
(
&
pkt
,
dup
,
BUF_LEN
-
1
,
&
len
))
{
fprintf
(
stderr
,
"test_PACKET_copy_bytes() failed
\n
"
);
return
0
;
}
return
1
;
}
static
int
test_PACKET_memdup
(
unsigned
char
buf
[
BUF_LEN
])
{
unsigned
char
*
data
=
NULL
;
...
...
@@ -314,7 +333,7 @@ static int test_PACKET_buf_init()
unsigned
char
buf
[
BUF_LEN
];
PACKET
pkt
;
/* Also tests PACKET_
get_len
() */
/* Also tests PACKET_
remaining
() */
if
(
!
PACKET_buf_init
(
&
pkt
,
buf
,
4
)
||
PACKET_remaining
(
&
pkt
)
!=
4
||
!
PACKET_buf_init
(
&
pkt
,
buf
,
BUF_LEN
)
...
...
@@ -332,7 +351,6 @@ static int test_PACKET_null_init()
PACKET
pkt
;
PACKET_null_init
(
&
pkt
);
/* Also tests PACKET_get_len() */
if
(
PACKET_remaining
(
&
pkt
)
!=
0
||
PACKET_forward
(
&
pkt
,
1
))
{
fprintf
(
stderr
,
"test_PACKET_null_init() failed
\n
"
);
...
...
@@ -442,6 +460,7 @@ int main(int argc, char **argv)
||
!
test_PACKET_get_sub_packet
(
buf
)
||
!
test_PACKET_get_bytes
(
buf
)
||
!
test_PACKET_copy_bytes
(
buf
)
||
!
test_PACKET_copy_all
(
buf
)
||
!
test_PACKET_memdup
(
buf
)
||
!
test_PACKET_strndup
()
||
!
test_PACKET_forward
(
buf
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录