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>
This commit is contained in:
Fu Siyuan 2017-09-20 11:21:56 +08:00
parent 85974aef13
commit b07bbb4f73
1 changed files with 5 additions and 1 deletions

View File

@ -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;
}