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: [email protected]
> Cc: Wu, Jiaxin <[email protected]>; Ye, Ting <[email protected]>; Michael
> Turner <[email protected]>
> 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 <[email protected]>
> Cc: Wu Jiaxin <[email protected]>
> Cc: Ye Ting <[email protected]>
> Cc: Michael Turner <[email protected]>
> ---
> 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
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel