diff options
author | Eric Dong <eric.dong@intel.com> | 2014-06-26 03:24:25 +0000 |
---|---|---|
committer | ydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-06-26 03:24:25 +0000 |
commit | 523f48e771b1088c6e2cfddc5c56cde1ef9a2ab0 (patch) | |
tree | 91d3cdacf538e40a24922981037cd413af4f6123 /MdeModulePkg/Universal | |
parent | d0f65b21c58b958ba370e774c6fe3ddc5ff1f3c7 (diff) | |
download | edk2-platforms-523f48e771b1088c6e2cfddc5c56cde1ef9a2ab0.tar.xz |
Refine code to make it more safely.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15598 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
17 files changed, 45 insertions, 15 deletions
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index 10eef05098..84c6c9af1f 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -388,7 +388,7 @@ SetPassword ( //
// Get user input password
//
- Password = &PrivateData->Configuration.WhatIsThePassword2[0];
+ Password = PrivateData->Configuration.WhatIsThePassword2;
PasswordSize = sizeof (PrivateData->Configuration.WhatIsThePassword2);
ZeroMem (Password, PasswordSize);
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 0011c53e6f..f5e054d265 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -4339,6 +4339,7 @@ HiiConfigRoutingRouteConfig ( );
}
if (EFI_ERROR (Status)) {
+ ASSERT (AccessProgress != NULL);
//
// AccessProgress indicates the parsing progress on <ConfigResp>.
// Map it to the progress on <MultiConfigResp> then return it.
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index 65334ded5e..01d7f02234 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -1,7 +1,7 @@ /** @file
Implementation for EFI_HII_DATABASE_PROTOCOL.
-Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2014, 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
@@ -2419,6 +2419,7 @@ AddPackages ( //
StringPkgIsAdd = FALSE;
FontPackage = NULL;
+ StringPackage = NULL;
//
// Process the package list header
@@ -2505,6 +2506,7 @@ AddPackages ( if (EFI_ERROR (Status)) {
return Status;
}
+ ASSERT (StringPackage != NULL);
Status = InvokeRegisteredFunction (
Private,
NotifyType,
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c index 24bb502996..eef31d5bb8 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -2,7 +2,7 @@ Implementation for EFI_HII_FONT_PROTOCOL.
-Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2014, 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
@@ -1040,8 +1040,12 @@ IsSystemFontInfo ( return TRUE;
}
+ SystemDefault = NULL;
+ DefaultLen = 0;
+
Status = GetSystemFont (Private, &SystemDefault, &DefaultLen);
ASSERT_EFI_ERROR (Status);
+ ASSERT ((SystemDefault != NULL) && (DefaultLen != 0));
//
// Record the system default info.
@@ -1687,6 +1691,7 @@ HiiStringToImage ( SysFontFlag = IsSystemFontInfo (Private, (EFI_FONT_DISPLAY_INFO *) StringInfo, &SystemDefault, NULL);
if (SysFontFlag) {
+ ASSERT (SystemDefault != NULL);
FontInfo = NULL;
Height = SystemDefault->FontInfo.FontSize;
BaseLine = SystemDefault->FontInfo.FontSize;
@@ -2580,6 +2585,7 @@ HiiGetGlyph ( Foreground = StringInfoOut->ForegroundColor;
Background = StringInfoOut->BackgroundColor;
} else {
+ ASSERT (SystemDefault != NULL);
Foreground = SystemDefault->ForegroundColor;
Background = SystemDefault->BackgroundColor;
}
@@ -2723,6 +2729,7 @@ HiiGetFontInfo ( return EFI_INVALID_PARAMETER;
}
+ StringInfoOutLen = 0;
FontInfo = NULL;
SystemDefault = NULL;
LocalFontHandle = NULL;
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c index efa5bbb71b..ed0cf83c48 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c @@ -2,7 +2,7 @@ Implementation for EFI_HII_IMAGE_PROTOCOL.
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2014, 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
@@ -1237,6 +1237,7 @@ HiiDrawImage ( return EFI_INVALID_PARAMETER;
}
+ FontInfo = NULL;
ImageIn = (EFI_IMAGE_INPUT *) Image;
//
@@ -1383,6 +1384,7 @@ HiiDrawImage ( FreePool (ImageOut);
return Status;
}
+ ASSERT (FontInfo != NULL);
for (Index = 0; Index < Width * Height; Index++) {
BltBuffer[Index] = FontInfo->BackgroundColor;
}
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c index 19ad101d54..995bbcf840 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c @@ -1,7 +1,7 @@ /** @file
EFI DHCP protocol implementation.
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, 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
@@ -404,6 +404,7 @@ DhcpLeaseAcquired ( if (DhcpSb->Netmask == 0) {
Class = NetGetIpClass (DhcpSb->ClientAddr);
+ ASSERT (Class < IP4_ADDR_CLASSE);
DhcpSb->Netmask = gIp4AllMasks[Class << 3];
}
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index a9c6df9db9..f8ae161b4c 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c @@ -227,6 +227,7 @@ IScsiUpdateDeviceList ( );
if (Status == EFI_BUFFER_TOO_SMALL) {
DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DataSize);
+ ASSERT (DeviceList != NULL);
gRT->GetVariable (
L"iSCSIDeviceList",
@@ -291,6 +292,7 @@ IScsiUpdateDeviceList ( //
DeviceListSize = sizeof (ISCSI_DEVICE_LIST) + (NumHandles - 1) * sizeof (ISCSI_MAC_INFO);
DeviceList = (ISCSI_DEVICE_LIST *) AllocatePool (DeviceListSize);
+ ASSERT (DeviceList != NULL);
DeviceList->NumDevice = (UINT8) NumHandles;
for (Index = 0; Index < NumHandles; Index++) {
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index a00d805b84..1cb1fb89d9 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -219,6 +219,7 @@ IScsiLunToUnicodeStr ( TempStr += StrLen (TempStr);
}
+ ASSERT (StrLen(Str) >= 1);
Str[StrLen (Str) - 1] = 0;
for (Index = StrLen (Str) - 1; Index > 1; Index = Index - 2) {
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c index e4ab17a37e..3c29f75f88 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.c @@ -1,7 +1,7 @@ /** @file
Implement IP4 pesudo interface.
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2014, 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
@@ -582,6 +582,7 @@ Ip4SetAddress ( Type = NetGetIpClass (IpAddr);
Len = NetGetMaskLength (SubnetMask);
+ ASSERT (Len >= 1);
Netmask = gIp4AllMasks[MIN ((Len - 1), Type << 3)];
Interface->NetBrdcast = (IpAddr | ~Netmask);
diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c index ae157c5e0a..21547ee3af 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Rrq.c @@ -1,7 +1,7 @@ /** @file
Routines to process Rrq (download).
-Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, 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
@@ -704,6 +704,7 @@ Mtftp4RrqInput ( } else {
Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
+ ASSERT (Packet != NULL);
}
Opcode = NTOHS (Packet->OpCode);
diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c index 412c472e42..e825714700 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Wrq.c @@ -1,7 +1,7 @@ /** @file
Routines to process Wrq (upload).
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2014, 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
@@ -398,6 +398,7 @@ Mtftp4WrqInput ( } else {
Packet = (EFI_MTFTP4_PACKET *) NetbufGetByte (UdpPacket, 0, NULL);
+ ASSERT (Packet != NULL);
}
Opcode = NTOHS (Packet->OpCode);
diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c index ed583b4888..ff93167767 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.c @@ -1,7 +1,7 @@ /** @file
Implementation of driver entry point and driver binding protocol.
-Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2014, 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
@@ -545,8 +545,8 @@ SimpleNetworkDriverStart ( // the IO BAR. Save the index of the BAR into the adapter info structure.
// for regular 32bit BARs, 0 is memory mapped, 1 is io mapped
//
- ConfigHeader = (PCI_TYPE00 *) &ConfigInfo.Config.Byte[0];
- TempBar = (UINT32 *) &ConfigHeader->Device.Bar[0];
+ ConfigHeader = (PCI_TYPE00 *) ConfigInfo.Config.Byte;
+ TempBar = (UINT32 *) ConfigHeader->Device.Bar;
for (BarIndex = 0; BarIndex <= 5; BarIndex++) {
if ((*TempBar & PCI_BAR_MEM_MASK) == PCI_BAR_MEM_64BIT) {
//
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c index e016cc0f51..1293f67268 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c @@ -477,6 +477,7 @@ PxeBcCheckSelectedOffer ( //
Status = EFI_NO_RESPONSE;
+ ASSERT (Private->NumOffers < PXEBC_MAX_OFFER_NUM);
for (Index = 0; Index < Private->NumOffers; Index++) {
Offer = &Private->Dhcp4Offers[Index].Packet.Offer;
diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c index 3c55a785fc..0f0da166ad 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideDxe.c @@ -123,10 +123,11 @@ DevicePathToStr ( TRUE
);
if (Text == NULL) {
- return AllocateCopyPool (sizeof (L"?"), L"?");
- } else {
- return Text;
+ Text = AllocateCopyPool (sizeof (L"?"), L"?");
+ ASSERT (Text != NULL);
}
+
+ return Text;
}
/**
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index e806b504b2..22f257dd4e 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -1,7 +1,7 @@ /** @file
Parser for IFR binary encoding.
-Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2014, 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
@@ -663,6 +663,7 @@ InitializeRequestElement ( ASSERT (ConfigInfo != NULL);
ConfigInfo->Signature = FORM_BROWSER_CONFIG_REQUEST_SIGNATURE;
ConfigInfo->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
+ ASSERT (ConfigInfo->ConfigRequest != NULL);
ConfigInfo->SpareStrLen = 0;
ConfigInfo->Storage = Storage;
InsertTailList(&Form->ConfigRequestHead, &ConfigInfo->Link);
@@ -2327,6 +2328,7 @@ ParseOpCodes ( break;
case EFI_IFR_ONE_OF_OPTION_OP:
+ ASSERT (CurrentOption != NULL);
ImageId = &CurrentOption->ImageId;
break;
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index bad8b7b122..f06b8a20d4 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -397,8 +397,11 @@ UpdateHotkeyList ( HotKey = BROWSER_HOT_KEY_FROM_LINK (Link);
CopyKey = AllocateCopyPool(sizeof (BROWSER_HOT_KEY), HotKey);
+ ASSERT (CopyKey != NULL);
CopyKey->KeyData = AllocateCopyPool(sizeof (EFI_INPUT_KEY), HotKey->KeyData);
+ ASSERT (CopyKey->KeyData != NULL);
CopyKey->HelpString = AllocateCopyPool(StrSize (HotKey->HelpString), HotKey->HelpString);
+ ASSERT (CopyKey->HelpString != NULL);
InsertTailList(&gDisplayFormData.HotKeyListHead, &CopyKey->Link);
@@ -1977,6 +1980,7 @@ ProcessCallBackFunction ( if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {
BackUpBuffer = AllocateCopyPool(Statement->StorageWidth + sizeof(CHAR16), Statement->BufferValue);
+ ASSERT (BackUpBuffer != NULL);
} else {
CopyMem (&BackUpValue, &HiiValue->Value, sizeof (EFI_IFR_TYPE_VALUE));
}
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 3f2f1b5468..4ba0cb0903 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -4060,8 +4060,11 @@ GetDefaultForFormset ( }
TmpNode = AllocateCopyPool (sizeof (NAME_VALUE_NODE), Node);
+ ASSERT (TmpNode != NULL);
TmpNode->Name = AllocateCopyPool (StrSize(Node->Name) * sizeof (CHAR16), Node->Name);
+ ASSERT (TmpNode->Name != NULL);
TmpNode->EditValue = AllocateCopyPool (StrSize(Node->EditValue) * sizeof (CHAR16), Node->EditValue);
+ ASSERT (TmpNode->EditValue != NULL);
InsertTailList(&BackUpList, &TmpNode->Link);
}
|