diff options
author | Fu Siyuan <siyuan.fu@intel.com> | 2017-09-20 11:21:56 +0800 |
---|---|---|
committer | Fu Siyuan <siyuan.fu@intel.com> | 2017-09-28 15:36:49 +0800 |
commit | b07bbb4f73c9d2abbdab5db0b064379981db11bc (patch) | |
tree | bec21c1d3ae9fad6b62d19e99191abe61cf10440 /MdeModulePkg | |
parent | 85974aef1332d2d8f480f121875dc57795220dd1 (diff) | |
download | edk2-b07bbb4f73c9d2abbdab5db0b064379981db11bc.tar.gz edk2-b07bbb4f73c9d2abbdab5db0b064379981db11bc.tar.bz2 edk2-b07bbb4f73c9d2abbdab5db0b064379981db11bc.zip |
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>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Diffstat (limited to 'MdeModulePkg')
-rw-r--r-- | MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c index 95cb71714b..d0e2b9f2a8 100644 --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c @@ -1,7 +1,7 @@ /** @file
Network library functions providing net buffer operation support.
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1175,6 +1175,10 @@ NetbufTrim ( NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);
+ if (Len == 0 || Nbuf->TotalSize == 0) {
+ return 0;
+ }
+
if (Len > Nbuf->TotalSize) {
Len = Nbuf->TotalSize;
}
|