]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Fix the potential issue in NetbufGetFragment() when Last is zero in Line 53.
authortye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 27 Jan 2010 09:30:35 +0000 (09:30 +0000)
committertye1 <tye1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 27 Jan 2010 09:30:35 +0000 (09:30 +0000)
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

index eadffbb45d6ae88c0e3d1a4567bb63d54ead4bdd..b56d62c8fb86f52610a5f23ef93d2767a95978bf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Network library functions providing net buffer operation support.\r
 \r
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>\r
 All rights reserved. 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
@@ -508,7 +508,6 @@ NetbufGetFragmentFree (
 }\r
 \r
 \r
-\r
 /**\r
   Create a NET_BUF structure which contains Len byte data of Nbuf starting from\r
   Offset.\r
@@ -579,9 +578,6 @@ NetbufGetFragment (
   FirstSkip = Offset - Cur;\r
   FirstLen  = BlockOp[Index].Size - FirstSkip;\r
 \r
-  //\r
-  //redundant assignment to make compiler happy.\r
-  //\r
   Last      = 0;\r
   LastLen   = 0;\r
 \r
@@ -605,6 +601,7 @@ NetbufGetFragment (
     FirstLen = Len;\r
   }\r
 \r
+  ASSERT (Last >= First);\r
   BlockOpNum = Last - First + 1;\r
   CurBlockOp = 0;\r
 \r
@@ -640,7 +637,7 @@ NetbufGetFragment (
     Child->BlockOp[0].Size =  0;\r
     CurBlockOp++;\r
 \r
-  }else {\r
+  } else {\r
     Child = NetbufAllocStruct (0, BlockOpNum);\r
 \r
     if (Child == NULL) {\r
@@ -664,7 +661,7 @@ NetbufGetFragment (
     CurBlockOp++\r
     );\r
 \r
-  for (Index = First + 1; Index <= Last - 1 ; Index++) {\r
+  for (Index = First + 1; Index < Last; Index++) {\r
     NetbufSetBlockOp (\r
       Child,\r
       BlockOp[Index].Head,\r