From 90f1486c8ebc891e3c69fc98d8efa372b0c4806c Mon Sep 17 00:00:00 2001 From: tye1 Date: Wed, 27 Jan 2010 09:30:35 +0000 Subject: [PATCH 1/1] 1. Fix the potential issue in NetbufGetFragment() when Last is zero in Line 53. 2. Comments update. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9837 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c index eadffbb45d..b56d62c8fb 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 - 2009, Intel Corporation.
+Copyright (c) 2005 - 2010, Intel Corporation.
All rights reserved. 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 @@ -508,7 +508,6 @@ NetbufGetFragmentFree ( } - /** Create a NET_BUF structure which contains Len byte data of Nbuf starting from Offset. @@ -579,9 +578,6 @@ NetbufGetFragment ( FirstSkip = Offset - Cur; FirstLen = BlockOp[Index].Size - FirstSkip; - // - //redundant assignment to make compiler happy. - // Last = 0; LastLen = 0; @@ -605,6 +601,7 @@ NetbufGetFragment ( FirstLen = Len; } + ASSERT (Last >= First); BlockOpNum = Last - First + 1; CurBlockOp = 0; @@ -640,7 +637,7 @@ NetbufGetFragment ( Child->BlockOp[0].Size = 0; CurBlockOp++; - }else { + } else { Child = NetbufAllocStruct (0, BlockOpNum); if (Child == NULL) { @@ -664,7 +661,7 @@ NetbufGetFragment ( CurBlockOp++ ); - for (Index = First + 1; Index <= Last - 1 ; Index++) { + for (Index = First + 1; Index < Last; Index++) { NetbufSetBlockOp ( Child, BlockOp[Index].Head, -- 2.39.2