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

Reply via email to