Revision: 13928
http://edk2.svn.sourceforge.net/edk2/?rev=13928&view=rev
Author: vanjeff
Date: 2012-11-05 03:34:52 +0000 (Mon, 05 Nov 2012)
Log Message:
-----------
Sync patches r13852, r13856, r13903 and r13907 from main trunk.
Fix code potential errors and add more check to make code more safely.
Revision Links:
--------------
http://edk2.svn.sourceforge.net/edk2/?rev=13852&view=rev
http://edk2.svn.sourceforge.net/edk2/?rev=13856&view=rev
http://edk2.svn.sourceforge.net/edk2/?rev=13903&view=rev
http://edk2.svn.sourceforge.net/edk2/?rev=13907&view=rev
Modified Paths:
--------------
branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.c
branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.h
Modified: branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -473,6 +473,7 @@
if (BlockIo != NULL) {
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO (BlockIo);
} else {
+ ASSERT (BlockIo2 != NULL);
AtaDevice = ATA_DEVICE_FROM_BLOCK_IO2 (BlockIo2);
}
Modified:
branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -133,6 +133,10 @@
if (TaskPacket != NULL) {
Packet = TaskPacket;
Packet->Asb = AllocateAlignedBuffer (AtaDevice, sizeof
(EFI_ATA_STATUS_BLOCK));
+ if (Packet->Asb == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
CopyMem (Packet->Asb, AtaDevice->Asb, sizeof (EFI_ATA_STATUS_BLOCK));
Packet->Acb = AllocateCopyPool (sizeof (EFI_ATA_COMMAND_BLOCK),
&AtaDevice->Acb);
} else {
@@ -948,6 +952,10 @@
AtaPassThru = AtaDevice->AtaBusDriverData->AtaPassThru;
if ((AtaPassThru->Mode->IoAlign > 1) && !IS_ALIGNED (Buffer,
AtaPassThru->Mode->IoAlign)) {
NewBuffer = AllocateAlignedBuffer (AtaDevice, TransferLength);
+ if (NewBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
CopyMem (NewBuffer, Buffer, TransferLength);
FreePool (Buffer);
Buffer = NewBuffer;
Modified: branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/Gcd/Gcd.c 2012-11-05
03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Core/Dxe/Gcd/Gcd.c 2012-11-05
03:34:52 UTC (rev 13928)
@@ -148,7 +148,7 @@
UINTN Index;
Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (Status == EFI_SUCCESS && MemorySpaceMap != NULL);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD Memory Space Map\n"));
@@ -190,7 +190,7 @@
UINTN Index;
Status = CoreGetIoSpaceMap (&NumberOfDescriptors, &IoSpaceMap);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (Status == EFI_SUCCESS && IoSpaceMap != NULL);
if (InitialMap) {
DEBUG ((DEBUG_GCD, "GCD:Initial GCD I/O Space Map\n"));
Modified: branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -240,6 +240,7 @@
// update is omitted.
//
Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL);
+ ASSERT (Icmp != NULL);
Icmp->Head.Type = ICMP_ECHO_REPLY;
Icmp->Head.Checksum = 0;
Icmp->Head.Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Icmp,
Data->TotalSize));
Modified: branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -1,7 +1,7 @@
/** @file
IP4 input process.
-Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2012, Intel Corporation. All rights reserved.<BR>
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
@@ -849,7 +849,8 @@
goto DROP;
}
- Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
+ Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Head != NULL);
OptionLen = (Head->HeadLen << 2) - IP4_MIN_HEADLEN;
if (OptionLen > 0) {
Option = (UINT8 *) (Head + 1);
@@ -899,6 +900,7 @@
// is transfered to the packet process logic.
//
Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Head != NULL);
Status = Ip4PreProcessPacket (
IpSb,
&Packet,
Modified:
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
===================================================================
---
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
2012-11-05 03:07:53 UTC (rev 13927)
+++
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Support.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -443,7 +443,7 @@
UDP_END_POINT UdpPoint;
EFI_STATUS Status;
UINT16 OpCode;
- UINT16 Value;
+ UINT8 *Buffer;
//
// Save the packet for retransmission
@@ -464,8 +464,9 @@
// Send the requests to the listening port, other packets
// to the connected port
//
- Value = *((UINT16 *) NetbufGetByte (Packet, 0, NULL));
- OpCode = NTOHS (Value);
+ Buffer = NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Buffer != NULL);
+ OpCode = NTOHS (*(UINT16 *)Buffer);
if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) ||
(OpCode == EFI_MTFTP4_OPCODE_DIR) ||
@@ -511,7 +512,7 @@
UDP_END_POINT UdpPoint;
EFI_STATUS Status;
UINT16 OpCode;
- UINT16 Value;
+ UINT8 *Buffer;
ASSERT (Instance->LastPacket != NULL);
@@ -521,8 +522,9 @@
//
// Set the requests to the listening port, other packets to the connected
port
//
- Value = *(UINT16 *) NetbufGetByte (Instance->LastPacket, 0, NULL);
- OpCode = NTOHS (Value);
+ Buffer = NetbufGetByte (Instance->LastPacket, 0, NULL);
+ ASSERT (Buffer != NULL);
+ OpCode = NTOHS (*(UINT16 *) Buffer);
if ((OpCode == EFI_MTFTP4_OPCODE_RRQ) || (OpCode == EFI_MTFTP4_OPCODE_DIR) ||
(OpCode == EFI_MTFTP4_OPCODE_WRQ)) {
Modified:
branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -711,6 +711,7 @@
Tcb = NULL;
Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
+ ASSERT (Head != NULL);
Len = Nbuf->TotalSize - (Head->HeadLen << 2);
if ((Head->HeadLen < 5) || (Len < 0) ||
@@ -1423,6 +1424,7 @@
BOOLEAN IcmpErrNotify;
Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
+ ASSERT (Head != NULL);
Tcb = TcpLocateTcb (
Head->DstPort,
Dst,
Modified: branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -592,6 +592,7 @@
Seg = TCPSEG_NETBUF (Nbuf);
Head = (TCP_HEAD *) NetbufGetByte (Nbuf, 0, NULL);
+ ASSERT (Head != NULL);
Nbuf->Tcp = Head;
Seg->Seq = NTOHL (Head->Seq);
Modified: branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
===================================================================
--- branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
2012-11-05 03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c
2012-11-05 03:34:52 UTC (rev 13928)
@@ -1612,6 +1612,7 @@
// Get the datagram header from the packet buffer.
//
Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Udp4Header != NULL);
if (Udp4Header->Checksum != 0) {
//
@@ -1799,6 +1800,7 @@
UDP4_INSTANCE_DATA *Instance;
Udp4Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
+ ASSERT (Udp4Header != NULL);
CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof
(EFI_IPv4_ADDRESS));
CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof
(EFI_IPv4_ADDRESS));
Modified: branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.c
===================================================================
--- branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.c 2012-11-05
03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.c 2012-11-05
03:34:52 UTC (rev 13928)
@@ -19,7 +19,7 @@
//
// The print title for IKEv1 variety phase.
//
-CHAR8 *mIkev1StateStr[] = {
+CHAR8 *mIkev1StateStr[IKE_STATE_NUM] = {
"IKEv1_MAIN_1",
"IKEv1_MAIN_2",
"IKEv1_MAIN_3",
@@ -32,7 +32,7 @@
//
// The print title for IKEv2 variety phase.
//
-CHAR8 *mIkev2StateStr[] = {
+CHAR8 *mIkev2StateStr[IKE_STATE_NUM] = {
"IKEv2_STATE_INIT",
"IKEv2_STATE_AUTH",
"IKEv2_STATE_SA_ESTABLISH",
@@ -166,23 +166,23 @@
IN UINT8 IkeVersion
)
{
+ if (Previous >= IKE_STATE_NUM || Current >= IKE_STATE_NUM) {
+ return;
+ }
if (Previous == Current) {
if (IkeVersion == 1) {
DEBUG ((DEBUG_INFO, "\n****Current state is %a\n",
mIkev1StateStr[Previous]));
} else if (IkeVersion == 2) {
DEBUG ((DEBUG_INFO, "\n****Current state is %a\n",
mIkev2StateStr[Previous]));
- }
-
+ }
} else {
if (IkeVersion == 1) {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n",
mIkev1StateStr[Previous], mIkev1StateStr[Current]));
} else {
DEBUG ((DEBUG_INFO, "\n****Change state from %a to %a\n",
mIkev2StateStr[Previous], mIkev2StateStr[Current]));
- }
-
+ }
}
-
}
/**
Modified: branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.h
===================================================================
--- branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.h 2012-11-05
03:07:53 UTC (rev 13927)
+++ branches/UDK2010.SR1/NetworkPkg/IpSecDxe/IpSecDebug.h 2012-11-05
03:34:52 UTC (rev 13928)
@@ -27,8 +27,10 @@
#define IPSEC_DUMP_BUF(Title, Data, DataSize) IpSecDumpBuf (Title,
Data, DataSize)
#define IPSEC_DEBUG_BYTE_PER_LINE 8
+#define IKE_STATE_NUM 7
+
/**
Print the IP address.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits