]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add security check.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Jun 2009 09:19:25 +0000 (09:19 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 29 Jun 2009 09:19:25 +0000 (09:19 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8680 6f19259b-4bc3-4df7-8a09-765794883524

22 files changed:
MdeModulePkg/Library/DxeNetLib/DxeNetLib.c
MdeModulePkg/Library/DxeNetLib/NetBuffer.c
MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.c
MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c
MdeModulePkg/Universal/Network/SnpDxe/Snp.c
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c

index 8bf2cbd3b668de28a19ce871791118e00e42ac44..32c81c17b77008126c461d7efa82ebc93ea73c0c 100644 (file)
@@ -1286,6 +1286,9 @@ NetLibDefaultAddressIsStatic (
   // Construct config request string header\r
   //\r
   ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);\r
   // Construct config request string header\r
   //\r
   ConfigHdr = HiiConstructConfigHdr (&gEfiNicIp4ConfigVariableGuid, EFI_NIC_IP4_CONFIG_VARIABLE, Controller);\r
+  if (ConfigHdr == NULL) {\r
+    return TRUE;\r
+  }\r
   \r
   Len = StrLen (ConfigHdr);\r
   ConfigResp = AllocateZeroPool ((Len + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
   \r
   Len = StrLen (ConfigHdr);\r
   ConfigResp = AllocateZeroPool ((Len + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));\r
index 61d49087e9ea36e07dc80fae715ee4869e11ff9e..3fbb6094a54cc564fc75a0dc1e16ed0a7428fa51 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Network library functions providing net buffer operation support.\r
   \r
 /** @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
 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
@@ -1506,6 +1506,8 @@ NetbufQueCopy (
     Cur += Nbuf->TotalSize;\r
   }\r
 \r
     Cur += Nbuf->TotalSize;\r
   }\r
 \r
+  ASSERT (Nbuf != NULL);\r
+\r
   //\r
   // Copy the data in the first buffer.\r
   //\r
   //\r
   // Copy the data in the first buffer.\r
   //\r
index d42937ef347de3c8a480d7d6c1560775b0853d27..aa4707294be595d035461c6424603437d3ff1f45 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of the ARP protocol.\r
   \r
 /** @file\r
   The implementation of the ARP protocol.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 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<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<BR>\r
@@ -1083,6 +1083,7 @@ ArpSendFrame (
   Packet = AllocatePool (TotalLength);\r
   if (Packet == NULL) {\r
     DEBUG ((EFI_D_ERROR, "ArpSendFrame: Allocate memory for Packet failed.\n"));\r
   Packet = AllocatePool (TotalLength);\r
   if (Packet == NULL) {\r
     DEBUG ((EFI_D_ERROR, "ArpSendFrame: Allocate memory for Packet failed.\n"));\r
+    ASSERT (Packet != NULL);\r
   }\r
 \r
   TmpPtr = Packet;\r
   }\r
 \r
   TmpPtr = Packet;\r
@@ -1451,6 +1452,7 @@ ArpFindCacheEntry (
   UINT32             FoundCount;\r
   EFI_ARP_FIND_DATA  *FindData;\r
   LIST_ENTRY         *CacheTable;\r
   UINT32             FoundCount;\r
   EFI_ARP_FIND_DATA  *FindData;\r
   LIST_ENTRY         *CacheTable;\r
+  UINT32             FoundEntryLength;\r
 \r
   ArpService = Instance->ArpService;\r
 \r
 \r
   ArpService = Instance->ArpService;\r
 \r
@@ -1567,12 +1569,14 @@ ArpFindCacheEntry (
     goto CLEAN_EXIT;\r
   }\r
 \r
     goto CLEAN_EXIT;\r
   }\r
 \r
+  //\r
+  // Found the entry length, make sure its 8 bytes alignment.\r
+  //\r
+  FoundEntryLength = (((sizeof (EFI_ARP_FIND_DATA) + Instance->ConfigData.SwAddressLength +\r
+                       ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3));\r
+\r
   if (EntryLength != NULL) {\r
   if (EntryLength != NULL) {\r
-    //\r
-    // Return the entry length, make sure its 8 bytes alignment.\r
-    //\r
-    *EntryLength = (((sizeof (EFI_ARP_FIND_DATA) + Instance->ConfigData.SwAddressLength +\r
-                   ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3));\r
+    *EntryLength = FoundEntryLength;\r
   }\r
 \r
   if (EntryCount != NULL) {\r
   }\r
 \r
   if (EntryCount != NULL) {\r
@@ -1589,7 +1593,7 @@ ArpFindCacheEntry (
   //\r
   // Allocate buffer to copy the found entries.\r
   //\r
   //\r
   // Allocate buffer to copy the found entries.\r
   //\r
-  FindData = AllocatePool (FoundCount * (*EntryLength));\r
+  FindData = AllocatePool (FoundCount * FoundEntryLength);\r
   if (FindData == NULL) {\r
     DEBUG ((EFI_D_ERROR, "ArpFindCacheEntry: Failed to allocate memory.\n"));\r
     Status = EFI_OUT_OF_RESOURCES;\r
   if (FindData == NULL) {\r
     DEBUG ((EFI_D_ERROR, "ArpFindCacheEntry: Failed to allocate memory.\n"));\r
     Status = EFI_OUT_OF_RESOURCES;\r
index f2c2100d363ef236bc2aeb92af8d1c5fb23a7185..6d82230457d8f06b604dc215ea9d9de7fffafb3b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file implement the EFI_DHCP4_PROTOCOL interface.\r
   \r
 /** @file\r
   This file implement the EFI_DHCP4_PROTOCOL interface.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -1313,12 +1313,13 @@ PxeDhcpInput (
   //\r
   Len  = NET_ROUNDUP (sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER), 4);\r
   Wrap = NetbufAlloc (Len);\r
   //\r
   Len  = NET_ROUNDUP (sizeof (EFI_DHCP4_PACKET) + UdpPacket->TotalSize - sizeof (EFI_DHCP4_HEADER), 4);\r
   Wrap = NetbufAlloc (Len);\r
-\r
   if (Wrap == NULL) {\r
     goto RESTART;\r
   }\r
 \r
   Packet         = (EFI_DHCP4_PACKET *) NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);\r
   if (Wrap == NULL) {\r
     goto RESTART;\r
   }\r
 \r
   Packet         = (EFI_DHCP4_PACKET *) NetbufAllocSpace (Wrap, Len, NET_BUF_TAIL);\r
+  ASSERT (Packet != NULL);\r
+\r
   Packet->Size   = Len;\r
   Head           = &Packet->Dhcp4.Header;\r
   Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);\r
   Packet->Size   = Len;\r
   Head           = &Packet->Dhcp4.Header;\r
   Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);\r
index e49e1e44f9fb5f728018ac4df7a8309f37ee48a0..11b8978b400581dc6add2a2ff943e4eb99d81e8d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Function to validate, parse, process the DHCP options.\r
   \r
 /** @file\r
   Function to validate, parse, process the DHCP options.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -668,8 +668,8 @@ DhcpValidateOptions (
   }\r
 \r
   AllOption = NULL;\r
   }\r
 \r
   AllOption = NULL;\r
-  Status    = DhcpParseOption (Packet, &Count, &AllOption);\r
 \r
 \r
+  Status = DhcpParseOption (Packet, &Count, &AllOption);\r
   if (EFI_ERROR (Status) || (Count == 0)) {\r
     return Status;\r
   }\r
   if (EFI_ERROR (Status) || (Count == 0)) {\r
     return Status;\r
   }\r
@@ -679,6 +679,7 @@ DhcpValidateOptions (
 \r
   for (Index = 0; Index < Count; Index++) {\r
     Option = &AllOption[Index];\r
 \r
   for (Index = 0; Index < Count; Index++) {\r
     Option = &AllOption[Index];\r
+    ASSERT (Option != NULL);\r
 \r
     //\r
     // Find the format of the option then validate it.\r
 \r
     //\r
     // Find the format of the option then validate it.\r
index b0e09d800200e812c32186782ec7c266e47f1f23..dc6567498fb87fc12b84059e69337397652c553b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration.\r
  \r
 /** @file\r
   This file is for Challenge-Handshake Authentication Protocol (CHAP) Configuration.\r
  \r
-Copyright (c) 2004 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2004 - 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
 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
@@ -165,8 +165,7 @@ IScsiCHAPOnRspReceived (
   //\r
   KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);\r
   if (KeyValueList == NULL) {\r
   //\r
   KeyValueList = IScsiBuildKeyValueList ((CHAR8 *) Data, Len);\r
   if (KeyValueList == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ON_EXIT;\r
+    return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   Status = EFI_PROTOCOL_ERROR;\r
   }\r
 \r
   Status = EFI_PROTOCOL_ERROR;\r
index 5275638d1336a28bb85641e222a84bd3bfe450ea..9eff1850bee6cab19d582cbed068fc7772b78548 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Miscellaneous routines for iSCSI driver.\r
 \r
 /** @file\r
   Miscellaneous routines for iSCSI driver.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2004 - 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
 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
@@ -744,6 +744,9 @@ IScsiGetTcpConnDevicePath (
   // Duplicate it.\r
   //\r
   DevicePath  = DuplicateDevicePath (DevicePath);\r
   // Duplicate it.\r
   //\r
   DevicePath  = DuplicateDevicePath (DevicePath);\r
+  if (DevicePath == NULL) {\r
+    return NULL;\r
+  }\r
 \r
   DPathNode   = (EFI_DEV_PATH *) DevicePath;\r
 \r
 \r
   DPathNode   = (EFI_DEV_PATH *) DevicePath;\r
 \r
index b7de203881f8a7136f2ee5a5cda983a619197c8c..a5b7c93ebe5236327f29e51bd6f3845b28315906 100644 (file)
@@ -736,6 +736,8 @@ Ip4FormCallback (
   case KEY_SAVE_CHANGES:\r
     Ip4ConfigInstance = Private->Current->Ip4ConfigInstance;\r
     NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));\r
   case KEY_SAVE_CHANGES:\r
     Ip4ConfigInstance = Private->Current->Ip4ConfigInstance;\r
     NicInfo = AllocateZeroPool (sizeof (NIC_IP4_CONFIG_INFO) + 2 * sizeof (EFI_IP4_ROUTE_TABLE));\r
+    ASSERT (NicInfo != NULL);\r
+\r
     NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);\r
 \r
     if (!Private->Current->SessionConfigData.Enabled) {\r
     NicInfo->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (NicInfo + 1);\r
 \r
     if (!Private->Current->SessionConfigData.Enabled) {\r
index 9cb71473128e835d16ba63f4206b72b03b1dc66e..dd2674d22400e11f05daef17db7aebde7ff872e9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implement IP4 pesudo interface.\r
   \r
 /** @file\r
   Implement IP4 pesudo interface.\r
   \r
-Copyright (c) 2005 - 2007, 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
 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
@@ -582,7 +582,7 @@ Ip4SetAddress (
 \r
   Type                      = NetGetIpClass (IpAddr);\r
   Len                       = NetGetMaskLength (SubnetMask);\r
 \r
   Type                      = NetGetIpClass (IpAddr);\r
   Len                       = NetGetMaskLength (SubnetMask);\r
-  Netmask                   = gIp4AllMasks[MIN (Len, Type << 3)];\r
+  Netmask                   = gIp4AllMasks[MIN ((Len - 1), Type << 3)];\r
   Interface->NetBrdcast     = (IpAddr | ~Netmask);\r
 \r
   //\r
   Interface->NetBrdcast     = (IpAddr | ~Netmask);\r
 \r
   //\r
index 9b201c2eae618b7bfb6604fb5e30e5330088bf70..7b56a6664c0468177498d8fafc9108e730080e89 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   This file implements the RFC2236: IGMP v2.\r
   \r
 /** @file\r
   This file implements the RFC2236: IGMP v2.\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
 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
@@ -192,6 +192,9 @@ Ip4SendIgmpMessage (
   NetbufReserve (Packet, IP4_MAX_HEADLEN);\r
 \r
   Igmp = (IGMP_HEAD *) NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);\r
   NetbufReserve (Packet, IP4_MAX_HEADLEN);\r
 \r
   Igmp = (IGMP_HEAD *) NetbufAllocSpace (Packet, sizeof (IGMP_HEAD), FALSE);\r
+  if (Igmp == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
 \r
   Igmp->Type        = Type;\r
   Igmp->MaxRespTime = 0;\r
 \r
   Igmp->Type        = Type;\r
   Igmp->MaxRespTime = 0;\r
index 362e084a7c8e9c6a6f98ceae3a19d36b745c4df5..84a39656f6a10e3e92dc4d37edc0e13dec4f8170 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
 /** @file\r
 \r
-Copyright (c) 2005 - 2007, 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
 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
@@ -1314,6 +1314,10 @@ Ip4Groups (
   // host byte order\r
   //\r
   if (JoinFlag) {\r
   // host byte order\r
   //\r
   if (JoinFlag) {\r
+    //  \r
+    // When JoinFlag is TRUE, GroupAddress shouldn't be NULL.\r
+    //\r
+    ASSERT (GroupAddress != NULL);\r
     CopyMem (&Group, GroupAddress, sizeof (IP4_ADDR));\r
 \r
     for (Index = 0; Index < IpInstance->GroupCount; Index++) {\r
     CopyMem (&Group, GroupAddress, sizeof (IP4_ADDR));\r
 \r
     for (Index = 0; Index < IpInstance->GroupCount; Index++) {\r
index 0f4948d46ada867b5acb74d80fbd23c4bd2294f4..964fb96a79f33bb38f3c5f0238e175cafb3f0e55 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   IP4 input process.\r
   \r
 /** @file\r
   IP4 input process.\r
   \r
-Copyright (c) 2005 - 2007, 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
 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
@@ -265,6 +265,10 @@ Ip4Reassemble (
 \r
     InsertHeadList (&Table->Bucket[Index], &Assemble->Link);\r
   }\r
 \r
     InsertHeadList (&Table->Bucket[Index], &Assemble->Link);\r
   }\r
+  //\r
+  // Assemble shouldn't be NULL here\r
+  //\r
+  ASSERT (Assemble != NULL);\r
 \r
   //\r
   // Find the point to insert the packet: before the first\r
 \r
   //\r
   // Find the point to insert the packet: before the first\r
index 3f64bf05d916ea533b0ddee704d647113e8c02c6..f5b6bbc8878e19c5fcced077ef5fe85567fc69f0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Routines to process Rrq (download).\r
   \r
 /** @file\r
   Routines to process Rrq (download).\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -99,7 +99,6 @@ Mtftp4RrqSendAck (
   NET_BUF                   *Packet;\r
 \r
   Packet = NetbufAlloc (sizeof (EFI_MTFTP4_ACK_HEADER));\r
   NET_BUF                   *Packet;\r
 \r
   Packet = NetbufAlloc (sizeof (EFI_MTFTP4_ACK_HEADER));\r
-\r
   if (Packet == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
   if (Packet == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -109,6 +108,7 @@ Mtftp4RrqSendAck (
                                 sizeof (EFI_MTFTP4_ACK_HEADER),\r
                                 FALSE\r
                                 );\r
                                 sizeof (EFI_MTFTP4_ACK_HEADER),\r
                                 FALSE\r
                                 );\r
+  ASSERT (Ack != NULL);\r
 \r
   Ack->Ack.OpCode   = HTONS (EFI_MTFTP4_OPCODE_ACK);\r
   Ack->Ack.Block[0] = HTONS (BlkNo);\r
 \r
   Ack->Ack.OpCode   = HTONS (EFI_MTFTP4_OPCODE_ACK);\r
   Ack->Ack.Block[0] = HTONS (BlkNo);\r
index be3c8c95f6c3ce31e3d783cbd248581fda83b3cb..5c8516f6307496fb60dabb078beaeb3ded02cbb2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support routines for Mtftp.\r
   \r
 /** @file\r
   Support routines for Mtftp.\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -291,6 +291,8 @@ Mtftp4SendRequest (
   }\r
 \r
   Packet         = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Nbuf, Len, FALSE);\r
   }\r
 \r
   Packet         = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Nbuf, Len, FALSE);\r
+  ASSERT (Packet != NULL);\r
+\r
   Packet->OpCode = HTONS (Instance->Operation);\r
   Cur            = Packet->Rrq.Filename;\r
   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Token->Filename);\r
   Packet->OpCode = HTONS (Instance->Operation);\r
   Cur            = Packet->Rrq.Filename;\r
   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Token->Filename);\r
@@ -335,12 +337,13 @@ Mtftp4SendError (
 \r
   Len     = (UINT32) (AsciiStrLen ((CHAR8 *) ErrInfo) + sizeof (EFI_MTFTP4_ERROR_HEADER));\r
   Packet  = NetbufAlloc (Len);\r
 \r
   Len     = (UINT32) (AsciiStrLen ((CHAR8 *) ErrInfo) + sizeof (EFI_MTFTP4_ERROR_HEADER));\r
   Packet  = NetbufAlloc (Len);\r
-\r
   if (Packet == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   TftpError         = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Packet, Len, FALSE);\r
   if (Packet == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
   TftpError         = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (Packet, Len, FALSE);\r
+  ASSERT (TftpError != NULL);\r
+\r
   TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);\r
   TftpError->Error.ErrorCode = HTONS (ErrCode);\r
 \r
   TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);\r
   TftpError->Error.ErrorCode = HTONS (ErrCode);\r
 \r
index cb39da48c8d451349d76a03e00d4a85e4c4ec5d3..872b2953c2897fa0a1b9fe469a97fb46ea8d4adb 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Routines to process Wrq (upload).\r
   \r
 /** @file\r
   Routines to process Wrq (upload).\r
   \r
-Copyright (c) 2006, Intel Corporation<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -52,6 +52,7 @@ Mtftp4WrqSendBlock (
   }\r
 \r
   Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);\r
   }\r
 \r
   Packet = (EFI_MTFTP4_PACKET *) NetbufAllocSpace (UdpPacket, MTFTP4_DATA_HEAD_LEN, FALSE);\r
+  ASSERT (Packet != NULL);\r
 \r
   Packet->Data.OpCode = HTONS (EFI_MTFTP4_OPCODE_DATA);\r
   Packet->Data.Block  = HTONS (BlockNum);\r
 \r
   Packet->Data.OpCode = HTONS (EFI_MTFTP4_OPCODE_DATA);\r
   Packet->Data.Block  = HTONS (BlockNum);\r
index 7e98baa8eb56bd3359cfb8b2d499958a99522fa9..213b724e5f6da7691df0fc338e3d9ba955f4189d 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
 /** @file\r
-    Implementation of driver entry point and driver binding protocol.\r
+  Implementation of driver entry point and driver binding protocol.\r
  \r
 Copyright (c) 2004 - 2009, Intel Corporation. <BR> \r
 All rights reserved. This program and the accompanying materials are licensed \r
  \r
 Copyright (c) 2004 - 2009, Intel Corporation. <BR> \r
 All rights reserved. This program and the accompanying materials are licensed \r
@@ -860,7 +860,7 @@ AddV2P (
   }\r
 \r
   *V2p = AllocatePool (sizeof (V2P));\r
   }\r
 \r
   *V2p = AllocatePool (sizeof (V2P));\r
-  if (*V2p != NULL) {\r
+  if (*V2p == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
index c9a1f6b106aa9cd495490a08e73192a420f8b168..956385a914d574930e1e76f68046b92a0b6a8406 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   TCP output process routines.\r
     \r
 /** @file\r
   TCP output process routines.\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
 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
@@ -445,7 +445,9 @@ TcpGetSegmentSndQue (
     }\r
   }\r
 \r
     }\r
   }\r
 \r
-  ASSERT (Cur != Head);\r
+  ASSERT (Cur  != Head);\r
+  ASSERT (Node != NULL);\r
+  ASSERT (Seg  != NULL);\r
 \r
   //\r
   // Return the buffer if it can be returned without\r
 \r
   //\r
   // Return the buffer if it can be returned without\r
@@ -750,6 +752,7 @@ SEND_AGAIN:
   Len   = TcpDataToSend (Tcb, Force);\r
   Seq   = Tcb->SndNxt;\r
 \r
   Len   = TcpDataToSend (Tcb, Force);\r
   Seq   = Tcb->SndNxt;\r
 \r
+  ASSERT ((Tcb->State) < (sizeof (mTcpOutFlag) / sizeof (mTcpOutFlag[0])));\r
   Flag  = mTcpOutFlag[Tcb->State];\r
 \r
   if ((Flag & TCP_FLG_SYN) != 0) {\r
   Flag  = mTcpOutFlag[Tcb->State];\r
 \r
   if ((Flag & TCP_FLG_SYN) != 0) {\r
index 0440f1558d8eb67ec26764236a62869d0385e2ab..0f14021e2397407b9ae63f4103f1dd5ac6311f69 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The implementation of the Udp4 protocol.\r
   \r
 /** @file\r
   The implementation of the Udp4 protocol.\r
   \r
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>                                                         \r
+Copyright (c) 2006 - 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
 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
@@ -1718,6 +1718,7 @@ Udp4SendPortUnreach (
   // Allocate space for the IP4_ICMP_ERROR_HEAD.\r
   //\r
   IcmpErrHdr = (IP4_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE);\r
   // Allocate space for the IP4_ICMP_ERROR_HEAD.\r
   //\r
   IcmpErrHdr = (IP4_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE);\r
+  ASSERT (IcmpErrHdr != NULL);\r
 \r
   //\r
   // Set the required fields for the icmp port unreachable message.\r
 \r
   //\r
   // Set the required fields for the icmp port unreachable message.\r
index a787ec440fac48037ee2183a4abf174fe9764ca3..f3ff95463c0aa10575d57c2b5b7f5d899cc5639b 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
 /** @file\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
+Copyright (c) 2006 - 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
 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
@@ -576,6 +576,8 @@ Udp4Transmit (
   *((UINTN *) &Packet->ProtoData[0]) = (UINTN) (Udp4Service->IpIo);\r
 \r
   Udp4Header = (EFI_UDP4_HEADER *) NetbufAllocSpace (Packet, UDP4_HEADER_SIZE, TRUE);\r
   *((UINTN *) &Packet->ProtoData[0]) = (UINTN) (Udp4Service->IpIo);\r
 \r
   Udp4Header = (EFI_UDP4_HEADER *) NetbufAllocSpace (Packet, UDP4_HEADER_SIZE, TRUE);\r
+  ASSERT (Udp4Header != NULL);\r
+\r
   ConfigData = &Instance->ConfigData;\r
 \r
   //\r
   ConfigData = &Instance->ConfigData;\r
 \r
   //\r
index ad7d139cf71719386fe24de444152f3ab8e0b7cf..9b5080f15dbafca09c2be10745f3381ef7f637d7 100644 (file)
@@ -274,6 +274,7 @@ PxeBcTryBinl (
   PXEBC_CACHED_DHCP4_PACKET *CachedPacket;\r
   EFI_DHCP4_PACKET          *Reply;\r
 \r
   PXEBC_CACHED_DHCP4_PACKET *CachedPacket;\r
   EFI_DHCP4_PACKET          *Reply;\r
 \r
+  ASSERT (Index < PXEBC_MAX_OFFER_NUM);\r
   ASSERT (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL);\r
 \r
   Offer = &Private->Dhcp4Offers[Index].Packet.Offer;\r
   ASSERT (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL);\r
 \r
   Offer = &Private->Dhcp4Offers[Index].Packet.Offer;\r
@@ -560,6 +561,7 @@ PxeBcCacheDhcpOffer (
   }\r
 \r
   OfferType = CachedOffer->OfferType;\r
   }\r
 \r
   OfferType = CachedOffer->OfferType;\r
+  ASSERT (OfferType < DHCP4_PACKET_TYPE_MAX);\r
 \r
   if (OfferType == DHCP4_PACKET_TYPE_BOOTP) {\r
 \r
 \r
   if (OfferType == DHCP4_PACKET_TYPE_BOOTP) {\r
 \r
@@ -603,6 +605,7 @@ PxeBcCacheDhcpOffer (
       //\r
       // It's a dhcp offer with your address.\r
       //\r
       //\r
       // It's a dhcp offer with your address.\r
       //\r
+      ASSERT (Private->ServerCount[OfferType] < PXEBC_MAX_OFFER_NUM);\r
       Private->OfferIndex[OfferType][Private->ServerCount[OfferType]] = Private->NumOffers;\r
       Private->ServerCount[OfferType]++;\r
     }\r
       Private->OfferIndex[OfferType][Private->ServerCount[OfferType]] = Private->NumOffers;\r
       Private->ServerCount[OfferType]++;\r
     }\r
@@ -1119,6 +1122,7 @@ PxeBcDiscvBootService (
   EFI_DHCP4_HEADER                    *DhcpHeader;\r
   UINT32                              Xid;\r
 \r
   EFI_DHCP4_HEADER                    *DhcpHeader;\r
   UINT32                              Xid;\r
 \r
+  ASSERT (IsDiscv && (Layer != NULL));\r
 \r
   Mode      = Private->PxeBc.Mode;\r
   Dhcp4     = Private->Dhcp4;\r
 \r
   Mode      = Private->PxeBc.Mode;\r
   Dhcp4     = Private->Dhcp4;\r
@@ -1717,15 +1721,21 @@ PxeBcSelectBootMenu (
   MenuSize  = VendorOpt->BootMenuLen;\r
   MenuItem  = VendorOpt->BootMenu;\r
 \r
   MenuSize  = VendorOpt->BootMenuLen;\r
   MenuItem  = VendorOpt->BootMenu;\r
 \r
+  if (MenuSize == 0) {\r
+    return EFI_NOT_READY;\r
+  }\r
+\r
   while (MenuSize > 0) {\r
     MenuArray[Index]  = MenuItem;\r
     MenuSize          = (UINT8) (MenuSize - (MenuItem->DescLen + 3));\r
     MenuItem          = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem + MenuItem->DescLen + 3);\r
   while (MenuSize > 0) {\r
     MenuArray[Index]  = MenuItem;\r
     MenuSize          = (UINT8) (MenuSize - (MenuItem->DescLen + 3));\r
     MenuItem          = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem + MenuItem->DescLen + 3);\r
-    Index++;\r
+    if (Index++ > (PXEBC_MAX_MENU_NUM - 1)) {\r
+      break;\r
+    }\r
   }\r
 \r
   if (UseDefaultItem) {\r
   }\r
 \r
   if (UseDefaultItem) {\r
-    CopyMem (Type, &MenuArray[0]->Type, sizeof (UINT16));\r
+    *Type = MenuArray[0]->Type;\r
     *Type = NTOHS (*Type);\r
     return EFI_SUCCESS;\r
   }\r
     *Type = NTOHS (*Type);\r
     return EFI_SUCCESS;\r
   }\r
index 15444c10836d36ac9f1cc7da05257ee3a7bbdff2..663d4a0202826dcd290d66708faeb881e663f304 100644 (file)
@@ -1432,6 +1432,8 @@ CheckIpByFilter (
     return TRUE;\r
   }\r
 \r
     return TRUE;\r
   }\r
 \r
+  ASSERT (PxeBcMode->IpFilter.IpCnt < EFI_PXE_BASE_CODE_MAX_IPCNT);\r
+\r
   for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) {\r
     CopyMem (\r
       &Ip4Address, \r
   for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) {\r
     CopyMem (\r
       &Ip4Address, \r
@@ -1755,20 +1757,20 @@ EfiPxeBcSetIpFilter (
   BOOLEAN                   PromiscuousNeed;\r
 \r
   if (This == NULL) {\r
   BOOLEAN                   PromiscuousNeed;\r
 \r
   if (This == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "BC *This pointer == NULL.\n"));\r
+    DEBUG ((EFI_D_ERROR, "This == NULL.\n"));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r
   Mode = Private->PxeBc.Mode;\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);\r
   Mode = Private->PxeBc.Mode;\r
 \r
-  if (Private == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "PXEBC_PRIVATE_DATA poiner == NULL.\n"));\r
+  if (NewFilter == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "NewFilter == NULL.\n"));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (NewFilter == NULL) {\r
-    DEBUG ((EFI_D_ERROR, "IP Filter *NewFilter == NULL.\n"));\r
+  if (NewFilter->IpCnt > EFI_PXE_BASE_CODE_MAX_IPCNT) {\r
+    DEBUG ((EFI_D_ERROR, "NewFilter->IpCnt > %d.\n", EFI_PXE_BASE_CODE_MAX_IPCNT));\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
@@ -1778,6 +1780,7 @@ EfiPxeBcSetIpFilter (
   }\r
 \r
   PromiscuousNeed = FALSE;\r
   }\r
 \r
   PromiscuousNeed = FALSE;\r
+\r
   for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r
     if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) {\r
       //\r
   for (Index = 0; Index < NewFilter->IpCnt; ++Index) {\r
     if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) {\r
       //\r
index 9327f6206731c39e99f5e2a1c3165834e9055231..087c2619aa0967956e31fbb046e23bae329f5020 100644 (file)
@@ -250,9 +250,10 @@ CvtNum (
 {\r
   UINTN Remainder;\r
 \r
 {\r
   UINTN Remainder;\r
 \r
-  while (Length-- > 0) {\r
+  while (Length > 0) {\r
     Remainder = Number % 10;\r
     Number /= 10;\r
     Remainder = Number % 10;\r
     Number /= 10;\r
+    Length--;\r
     Buffer[Length] = (UINT8) ('0' + Remainder);\r
   }\r
 }\r
     Buffer[Length] = (UINT8) ('0' + Remainder);\r
   }\r
 }\r