]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/DxeNetLib/NetBuffer.c
add security check.
[mirror_edk2.git] / MdeModulePkg / Library / DxeNetLib / NetBuffer.c
index a92efb71c0408e7f884e55d9c2556d56b6abd7fb..3fbb6094a54cc564fc75a0dc1e16ed0a7428fa51 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Network library functions providing net buffer operation support.\r
   \r
-Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r
+Copyright (c) 2005 - 2009, 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
@@ -168,7 +168,7 @@ NetbufFreeVector (
     // isn't NULL. If NET_VECTOR_OWN_FIRST is set, release the\r
     // first block since it is allocated by us\r
     //\r
-    if (Vector->Flag & NET_VECTOR_OWN_FIRST) {\r
+    if ((Vector->Flag & NET_VECTOR_OWN_FIRST) != 0) {\r
       gBS->FreePool (Vector->Block[0].Bulk);\r
     }\r
 \r
@@ -978,7 +978,7 @@ NetbufFromBufList (
     NET_CHECK_SIGNATURE (Nbuf, NET_BUF_SIGNATURE);\r
 \r
     for (Index = 0; Index < Nbuf->BlockOpNum; Index++) {\r
-      if (Nbuf->BlockOp[Index].Size) {\r
+      if (Nbuf->BlockOp[Index].Size != 0) {\r
         Fragment[Current].Bulk = Nbuf->BlockOp[Index].Head;\r
         Fragment[Current].Len  = Nbuf->BlockOp[Index].Size;\r
         Current++;\r
@@ -1223,7 +1223,7 @@ NetbufTrim (
   @param[in]   Dest         The destination of the data to copy to.\r
 \r
   @return           The length of the actual copied data, or 0 if the offset\r
-                    specified exceeds exceeds the total size of net buffer.\r
+                    specified exceeds the total size of net buffer.\r
 \r
 **/\r
 UINT32\r
@@ -1506,6 +1506,8 @@ NetbufQueCopy (
     Cur += Nbuf->TotalSize;\r
   }\r
 \r
+  ASSERT (Nbuf != NULL);\r
+\r
   //\r
   // Copy the data in the first buffer.\r
   //\r