]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeNetLib: Check the actual packet size before trim data from Nbuf.
authorFu Siyuan <siyuan.fu@intel.com>
Wed, 20 Sep 2017 03:21:56 +0000 (11:21 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 28 Sep 2017 07:36:49 +0000 (15:36 +0800)
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>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
MdeModulePkg/Library/DxeNetLib/NetBuffer.c

index 95cb71714b5bbb3afdd748db3415e6f065809ee5..d0e2b9f2a886043c5332816615ede4258b880efb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Network library functions providing net buffer operation support.\r
 \r
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1175,6 +1175,10 @@ NetbufTrim (
 \r
   NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);\r
 \r
+  if (Len == 0 || Nbuf->TotalSize == 0) {\r
+    return 0;\r
+  }\r
+\r
   if (Len > Nbuf->TotalSize) {\r
     Len = Nbuf->TotalSize;\r
   }\r