Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Lwip
提交
db4c7b70
T
Third Party Lwip
项目概览
OpenHarmony
/
Third Party Lwip
8 个月 前同步成功
通知
5
Star
23
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Lwip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
db4c7b70
编写于
8月 20, 2021
作者:
O
openharmony_ci
提交者:
Gitee
8月 20, 2021
浏览文件
操作
浏览文件
下载
差异文件
!13 修复漏洞CVE-2020-22284
Merge pull request !13 from 刘建东/master
上级
649762b2
e53e0a6a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
79 addition
and
1 deletion
+79
-1
src/core/pbuf.c
src/core/pbuf.c
+77
-0
src/include/lwip/pbuf.h
src/include/lwip/pbuf.h
+1
-0
src/netif/zepif.c
src/netif/zepif.c
+1
-1
未找到文件。
src/core/pbuf.c
浏览文件 @
db4c7b70
...
...
@@ -1011,6 +1011,83 @@ pbuf_copy(struct pbuf *p_to, const struct pbuf *p_from)
return
ERR_OK
;
}
/**
* @ingroup pbuf
* Copy part or all of one packet buffer into another, to a specified offset.
*
* @note Only data in one packet is copied, no packet queue!
* @note Argument order is shared with pbuf_copy, but different than pbuf_copy_partial.
*
* @param p_to pbuf destination of the copy
* @param p_from pbuf source of the copy
* @param copy_len number of bytes to copy
* @param offset offset in destination pbuf where to copy to
*
* @return ERR_OK if copy_len bytes were copied
* ERR_ARG if one of the pbufs is NULL or p_from is shorter than copy_len
* or p_to is not big enough to hold copy_len at offset
* ERR_VAL if any of the pbufs are part of a queue
*/
err_t
pbuf_copy_partial_pbuf
(
struct
pbuf
*
p_to
,
const
struct
pbuf
*
p_from
,
u16_t
copy_len
,
u16_t
offset
)
{
size_t
offset_to
=
offset
,
offset_from
=
0
,
len
;
LWIP_DEBUGF
(
PBUF_DEBUG
|
LWIP_DBG_TRACE
,
(
"pbuf_copy_partial_pbuf(%p, %p, %"
U16_F
", %"
U16_F
")
\n
"
,
(
const
void
*
)
p_to
,
(
const
void
*
)
p_from
,
copy_len
,
offset
));
/* is the copy_len in range? */
LWIP_ERROR
(
"pbuf_copy_partial_pbuf: copy_len bigger than source"
,
((
p_from
!=
NULL
)
&&
(
p_from
->
tot_len
>=
copy_len
)),
return
ERR_ARG
;);
/* is the target big enough to hold the source? */
LWIP_ERROR
(
"pbuf_copy_partial_pbuf: target not big enough"
,
((
p_to
!=
NULL
)
&&
(
p_to
->
tot_len
>=
(
offset
+
copy_len
))),
return
ERR_ARG
;);
/* iterate through pbuf chain */
do
{
/* copy one part of the original chain */
if
((
p_to
->
len
-
offset_to
)
>=
(
p_from
->
len
-
offset_from
))
{
/* complete current p_from fits into current p_to */
len
=
p_from
->
len
-
offset_from
;
}
else
{
/* current p_from does not fit into current p_to */
len
=
p_to
->
len
-
offset_to
;
}
len
=
LWIP_MIN
(
copy_len
,
len
);
MEMCPY
((
u8_t
*
)
p_to
->
payload
+
offset_to
,
(
u8_t
*
)
p_from
->
payload
+
offset_from
,
len
);
offset_to
+=
len
;
offset_from
+=
len
;
copy_len
-=
len
;
LWIP_ASSERT
(
"offset_to <= p_to->len"
,
offset_to
<=
p_to
->
len
);
LWIP_ASSERT
(
"offset_from <= p_from->len"
,
offset_from
<=
p_from
->
len
);
if
(
offset_from
>=
p_from
->
len
)
{
/* on to next p_from (if any) */
offset_from
=
0
;
p_from
=
p_from
->
next
;
LWIP_ERROR
(
"p_from != NULL"
,
(
p_from
!=
NULL
)
||
(
copy_len
==
0
),
return
ERR_ARG
;);
}
if
(
offset_to
==
p_to
->
len
)
{
/* on to next p_to (if any) */
offset_to
=
0
;
p_to
=
p_to
->
next
;
LWIP_ERROR
(
"p_to != NULL"
,
(
p_to
!=
NULL
)
||
(
copy_len
==
0
),
return
ERR_ARG
;);
}
if
((
p_from
!=
NULL
)
&&
(
p_from
->
len
==
p_from
->
tot_len
))
{
/* don't copy more than one packet! */
LWIP_ERROR
(
"pbuf_copy_partial_pbuf() does not allow packet queues!"
,
(
p_from
->
next
==
NULL
),
return
ERR_VAL
;);
}
if
((
p_to
!=
NULL
)
&&
(
p_to
->
len
==
p_to
->
tot_len
))
{
/* don't copy more than one packet! */
LWIP_ERROR
(
"pbuf_copy_partial_pbuf() does not allow packet queues!"
,
(
p_to
->
next
==
NULL
),
return
ERR_VAL
;);
}
}
while
(
copy_len
);
LWIP_DEBUGF
(
PBUF_DEBUG
|
LWIP_DBG_TRACE
,
(
"pbuf_copy_partial_pbuf: copy complete.
\n
"
));
return
ERR_OK
;
}
/**
* @ingroup pbuf
* Copy (part of) the contents of a packet buffer
...
...
src/include/lwip/pbuf.h
浏览文件 @
db4c7b70
...
...
@@ -293,6 +293,7 @@ void pbuf_cat(struct pbuf *head, struct pbuf *tail);
void
pbuf_chain
(
struct
pbuf
*
head
,
struct
pbuf
*
tail
);
struct
pbuf
*
pbuf_dechain
(
struct
pbuf
*
p
);
err_t
pbuf_copy
(
struct
pbuf
*
p_to
,
const
struct
pbuf
*
p_from
);
err_t
pbuf_copy_partial_pbuf
(
struct
pbuf
*
p_to
,
const
struct
pbuf
*
p_from
,
u16_t
copy_len
,
u16_t
offset
);
u16_t
pbuf_copy_partial
(
const
struct
pbuf
*
p
,
void
*
dataptr
,
u16_t
len
,
u16_t
offset
);
void
*
pbuf_get_contiguous
(
const
struct
pbuf
*
p
,
void
*
buffer
,
size_t
bufsize
,
u16_t
len
,
u16_t
offset
);
err_t
pbuf_take
(
struct
pbuf
*
buf
,
const
void
*
dataptr
,
u16_t
len
);
...
...
src/netif/zepif.c
浏览文件 @
db4c7b70
...
...
@@ -201,7 +201,7 @@ zepif_linkoutput(struct netif *netif, struct pbuf *p)
state
->
seqno
++
;
zep
->
len
=
(
u8_t
)
p
->
tot_len
;
err
=
pbuf_
take_at
(
q
,
p
->
payload
,
p
->
tot_len
,
sizeof
(
struct
zep_hdr
));
err
=
pbuf_
copy_partial_pbuf
(
q
,
p
,
p
->
tot_len
,
sizeof
(
struct
zep_hdr
));
if
(
err
==
ERR_OK
)
{
#if ZEPIF_LOOPBACK
zepif_udp_recv
(
netif
,
state
->
pcb
,
pbuf_clone
(
PBUF_RAW
,
PBUF_RAM
,
q
),
NULL
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录