// 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
/** @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
Cur += Nbuf->TotalSize;\r
}\r
\r
+ ASSERT (Nbuf != NULL);\r
+\r
//\r
// Copy the data in the first buffer.\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
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
UINT32 FoundCount;\r
EFI_ARP_FIND_DATA *FindData;\r
LIST_ENTRY *CacheTable;\r
+ UINT32 FoundEntryLength;\r
\r
ArpService = Instance->ArpService;\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
- //\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
// 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
/** @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
//\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
+ ASSERT (Packet != NULL);\r
+\r
Packet->Size = Len;\r
Head = &Packet->Dhcp4.Header;\r
Packet->Length = NetbufCopy (UdpPacket, 0, UdpPacket->TotalSize, (UINT8 *) Head);\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
}\r
\r
AllOption = NULL;\r
- Status = DhcpParseOption (Packet, &Count, &AllOption);\r
\r
+ Status = DhcpParseOption (Packet, &Count, &AllOption);\r
if (EFI_ERROR (Status) || (Count == 0)) {\r
return Status;\r
}\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
/** @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
//\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
/** @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
// Duplicate it.\r
//\r
DevicePath = DuplicateDevicePath (DevicePath);\r
+ if (DevicePath == NULL) {\r
+ return NULL;\r
+ }\r
\r
DPathNode = (EFI_DEV_PATH *) DevicePath;\r
\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
/** @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
\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
/** @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
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
/** @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
// 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
/** @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
\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
/** @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
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
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
/** @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
}\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
\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
+ ASSERT (TftpError != NULL);\r
+\r
TftpError->OpCode = HTONS (EFI_MTFTP4_OPCODE_ERROR);\r
TftpError->Error.ErrorCode = HTONS (ErrCode);\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
}\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
/** @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
\r
*V2p = AllocatePool (sizeof (V2P));\r
- if (*V2p != NULL) {\r
+ if (*V2p == NULL) {\r
return EFI_OUT_OF_RESOURCES;\r
}\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
}\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
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
/** @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
// 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
/** @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
*((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
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
}\r
\r
OfferType = CachedOffer->OfferType;\r
+ ASSERT (OfferType < DHCP4_PACKET_TYPE_MAX);\r
\r
if (OfferType == DHCP4_PACKET_TYPE_BOOTP) {\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
EFI_DHCP4_HEADER *DhcpHeader;\r
UINT32 Xid;\r
\r
+ ASSERT (IsDiscv && (Layer != NULL));\r
\r
Mode = Private->PxeBc.Mode;\r
Dhcp4 = Private->Dhcp4;\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
- Index++;\r
+ if (Index++ > (PXEBC_MAX_MENU_NUM - 1)) {\r
+ break;\r
+ }\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
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
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
- 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
- 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
}\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
{\r
UINTN Remainder;\r
\r
- while (Length-- > 0) {\r
+ while (Length > 0) {\r
Remainder = Number % 10;\r
Number /= 10;\r
+ Length--;\r
Buffer[Length] = (UINT8) ('0' + Remainder);\r
}\r
}\r