* [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf.
@ 2017-09-20 3:23 Fu Siyuan
2017-09-20 8:16 ` Wu, Jiaxin
0 siblings, 1 reply; 2+ messages in thread
From: Fu Siyuan @ 2017-09-20 3:23 UTC (permalink / raw)
To: edk2-devel; +Cc: Wu Jiaxin, Ye Ting, Michael Turner
In NetbufTrim() function, the NetBuf TotalSize should be checked with 0 before
making the trim operation, otherwise the function will fall into infinite loop.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
---
MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
index 95cb71714b..25fc78e49e 100644
--- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
+++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
@@ -1175,6 +1175,10 @@ NetbufTrim (
NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
+ if (Nbuf->TotalSize == 0) {
+ return 0;
+ }
+
if (Len > Nbuf->TotalSize) {
Len = Nbuf->TotalSize;
}
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf.
2017-09-20 3:23 [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf Fu Siyuan
@ 2017-09-20 8:16 ` Wu, Jiaxin
0 siblings, 0 replies; 2+ messages in thread
From: Wu, Jiaxin @ 2017-09-20 8:16 UTC (permalink / raw)
To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Michael Turner
Hi Siyuan,
Maybe we can add more check for the Len to return directly, what do you think?
if (Len == 0) {
return 0;
}
> + if (Nbuf->TotalSize == 0) {
> + return 0;
> + }
Thanks,
Jiaxin
> -----Original Message-----
> From: Fu, Siyuan
> Sent: Wednesday, September 20, 2017 11:24 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Michael
> Turner <Michael.Turner@microsoft.com>
> Subject: [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size
> before trim data from Nbuf.
>
> In NetbufTrim() function, the NetBuf TotalSize should be checked with 0
> before
> making the trim operation, otherwise the function will fall into infinite loop.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
> Cc: Wu Jiaxin <jiaxin.wu@intel.com>
> Cc: Ye Ting <ting.ye@intel.com>
> Cc: Michael Turner <Michael.Turner@microsoft.com>
> ---
> MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> index 95cb71714b..25fc78e49e 100644
> --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c
> @@ -1175,6 +1175,10 @@ NetbufTrim (
>
> NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
>
> + if (Nbuf->TotalSize == 0) {
> + return 0;
> + }
> +
> if (Len > Nbuf->TotalSize) {
> Len = Nbuf->TotalSize;
> }
> --
> 2.13.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-20 8:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-20 3:23 [Patch] MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf Fu Siyuan
2017-09-20 8:16 ` Wu, Jiaxin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox