mirror of https://github.com/acidanthera/audk.git
Add more check to make sure code run safely.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10574 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
61ece967cb
commit
4ac4deb706
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -75,7 +75,7 @@ Returns:
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Put break point in module that contained the error.
|
// Put dead loop in module that contained the error.
|
||||||
//
|
//
|
||||||
EFI_DEADLOOP ();
|
EFI_DEADLOOP ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -825,6 +825,11 @@ Returns:
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize 'LogHob' to NULL before usage.
|
||||||
|
//
|
||||||
|
LogHob = NULL;
|
||||||
|
|
||||||
if (Ticker != 0) {
|
if (Ticker != 0) {
|
||||||
TimerValue = Ticker;
|
TimerValue = Ticker;
|
||||||
} else {
|
} else {
|
||||||
|
@ -837,7 +842,10 @@ Returns:
|
||||||
EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
|
EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
|
||||||
do {
|
do {
|
||||||
Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);
|
Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (LogHob == NULL)) {
|
||||||
|
//
|
||||||
|
// Failed to get HOB for ProtocolGuid.
|
||||||
|
//
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -436,11 +436,13 @@ Returns:
|
||||||
if (GraphicsOutput != NULL) {
|
if (GraphicsOutput != NULL) {
|
||||||
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
||||||
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
||||||
} else {
|
} else if (UgaDraw != NULL) {
|
||||||
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance = 0;
|
Instance = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -158,8 +158,7 @@ Arguments:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_SUCCESS - success
|
Length of string printed to the console
|
||||||
EFI_OUT_OF_RESOURCES - out of resources
|
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
|
@ -191,7 +190,7 @@ Returns:
|
||||||
//
|
//
|
||||||
Buffer = EfiLibAllocateZeroPool (0x10000);
|
Buffer = EfiLibAllocateZeroPool (0x10000);
|
||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GraphicsOutput != NULL) {
|
if (GraphicsOutput != NULL) {
|
||||||
|
@ -371,10 +370,15 @@ Error:
|
||||||
EfiLibSafeFreePool (Blt);
|
EfiLibSafeFreePool (Blt);
|
||||||
EfiLibSafeFreePool (FontInfo);
|
EfiLibSafeFreePool (FontInfo);
|
||||||
#else
|
#else
|
||||||
gBS->FreePool (LineBuffer);
|
EfiLibSafeFreePool (LineBuffer);
|
||||||
#endif
|
#endif
|
||||||
gBS->FreePool (Buffer);
|
gBS->FreePool (Buffer);
|
||||||
return Status;
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BufferLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,19 +444,20 @@ Returns:
|
||||||
(VOID**)&UgaDraw
|
(VOID**)&UgaDraw
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (UgaDraw == NULL)) {
|
||||||
return Status;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sto = NULL;
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
Handle,
|
Handle,
|
||||||
&gEfiSimpleTextOutProtocolGuid,
|
&gEfiSimpleTextOutProtocolGuid,
|
||||||
(VOID**)&Sto
|
(VOID**)&Sto
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (Sto == NULL)) {
|
||||||
return Status;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
|
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -123,8 +123,8 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
|
|
||||||
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
||||||
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
||||||
|
@ -132,7 +132,7 @@ Returns:
|
||||||
|
|
||||||
UnicodeFormat[Index] = '\0';
|
UnicodeFormat[Index] = '\0';
|
||||||
|
|
||||||
Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
|
Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
|
||||||
|
|
||||||
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
||||||
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -435,11 +435,13 @@ Returns:
|
||||||
if (GraphicsOutput != NULL) {
|
if (GraphicsOutput != NULL) {
|
||||||
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
|
||||||
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
|
||||||
} else {
|
} else if (UgaDraw != NULL) {
|
||||||
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance = 0;
|
Instance = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -125,8 +125,7 @@ Arguments:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
EFI_SUCCESS - success
|
Length of string printed to the console
|
||||||
EFI_OUT_OF_RESOURCES - out of resources
|
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
|
@ -158,7 +157,7 @@ Returns:
|
||||||
//
|
//
|
||||||
Buffer = EfiLibAllocateZeroPool (0x10000);
|
Buffer = EfiLibAllocateZeroPool (0x10000);
|
||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GraphicsOutput != NULL) {
|
if (GraphicsOutput != NULL) {
|
||||||
|
@ -337,10 +336,15 @@ Error:
|
||||||
EfiLibSafeFreePool (Blt);
|
EfiLibSafeFreePool (Blt);
|
||||||
EfiLibSafeFreePool (FontInfo);
|
EfiLibSafeFreePool (FontInfo);
|
||||||
#else
|
#else
|
||||||
gBS->FreePool (LineBuffer);
|
EfiLibSafeFreePool (LineBuffer);
|
||||||
#endif
|
#endif
|
||||||
gBS->FreePool (Buffer);
|
gBS->FreePool (Buffer);
|
||||||
return Status;
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return BufferLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,19 +410,20 @@ Returns:
|
||||||
(VOID **) &UgaDraw
|
(VOID **) &UgaDraw
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (UgaDraw != NULL)) {
|
||||||
return Status;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sto = NULL;
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
Handle,
|
Handle,
|
||||||
&gEfiSimpleTextOutProtocolGuid,
|
&gEfiSimpleTextOutProtocolGuid,
|
||||||
(VOID **) &Sto
|
(VOID **) &Sto
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (Sto != NULL)) {
|
||||||
return Status;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
|
return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -123,8 +123,8 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
|
|
||||||
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
||||||
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
||||||
|
@ -132,7 +132,7 @@ Returns:
|
||||||
|
|
||||||
UnicodeFormat[Index] = '\0';
|
UnicodeFormat[Index] = '\0';
|
||||||
|
|
||||||
Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
|
Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
|
||||||
|
|
||||||
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
||||||
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -466,6 +466,10 @@ Returns:
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VOID *HobStart2;
|
VOID *HobStart2;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize 'Buffer' to NULL before usage
|
||||||
|
//
|
||||||
|
Buffer = NULL;
|
||||||
HobStart2 = HobStart;
|
HobStart2 = HobStart;
|
||||||
Status = GetNextGuidHob (
|
Status = GetNextGuidHob (
|
||||||
&HobStart2,
|
&HobStart2,
|
||||||
|
@ -473,9 +477,14 @@ Returns:
|
||||||
&Buffer,
|
&Buffer,
|
||||||
&BufferSize
|
&BufferSize
|
||||||
);
|
);
|
||||||
|
if (EFI_ERROR (Status) || (Buffer == NULL)) {
|
||||||
|
//
|
||||||
|
// Failed to get HOB for gPalEntryHob
|
||||||
|
//
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
*PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);
|
*PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);
|
||||||
return Status;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -508,6 +517,10 @@ Returns:
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
VOID *HobStart2;
|
VOID *HobStart2;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize 'Buffer' to NULL before usage
|
||||||
|
//
|
||||||
|
Buffer = NULL;
|
||||||
HobStart2 = HobStart;
|
HobStart2 = HobStart;
|
||||||
Status = GetNextGuidHob (
|
Status = GetNextGuidHob (
|
||||||
&HobStart2,
|
&HobStart2,
|
||||||
|
@ -515,7 +528,13 @@ Returns:
|
||||||
&Buffer,
|
&Buffer,
|
||||||
&BufferSize
|
&BufferSize
|
||||||
);
|
);
|
||||||
|
if (EFI_ERROR (Status) || (Buffer == NULL)) {
|
||||||
|
//
|
||||||
|
// Failed to get HOB for gEfiIoBaseHobGuid
|
||||||
|
//
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
*IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);
|
*IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);
|
||||||
return Status;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -123,8 +123,8 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
|
|
||||||
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
||||||
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
||||||
|
@ -132,7 +132,7 @@ Returns:
|
||||||
|
|
||||||
UnicodeFormat[Index] = '\0';
|
UnicodeFormat[Index] = '\0';
|
||||||
|
|
||||||
Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
|
Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
|
||||||
|
|
||||||
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
||||||
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -123,8 +123,8 @@ Returns:
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
|
CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
|
||||||
|
|
||||||
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
|
||||||
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
UnicodeFormat[Index] = (CHAR16) FormatString[Index];
|
||||||
|
@ -132,7 +132,7 @@ Returns:
|
||||||
|
|
||||||
UnicodeFormat[Index] = '\0';
|
UnicodeFormat[Index] = '\0';
|
||||||
|
|
||||||
Index = VSPrint (UnicodeResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, UnicodeFormat, Marker);
|
Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker);
|
||||||
|
|
||||||
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
|
||||||
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
Buffer[Index] = (CHAR8) UnicodeResult[Index];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -554,7 +554,11 @@ Returns:
|
||||||
|
|
||||||
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
|
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
|
||||||
}
|
}
|
||||||
|
if (HiiPackageList == NULL) {
|
||||||
|
return EFI_OUT_OF_RESOURCES;
|
||||||
|
}
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
gBS->FreePool (HiiPackageList);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -551,6 +551,9 @@ IfrLibNewString (
|
||||||
LocateHiiProtocols ();
|
LocateHiiProtocols ();
|
||||||
|
|
||||||
Languages = GetSupportedLanguages (PackageList);
|
Languages = GetSupportedLanguages (PackageList);
|
||||||
|
if (Languages == NULL) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
LangStrings = Languages;
|
LangStrings = Languages;
|
||||||
while (*LangStrings != 0) {
|
while (*LangStrings != 0) {
|
||||||
|
@ -677,6 +680,9 @@ IfrLibSetString (
|
||||||
LocateHiiProtocols ();
|
LocateHiiProtocols ();
|
||||||
|
|
||||||
Languages = GetSupportedLanguages (PackageList);
|
Languages = GetSupportedLanguages (PackageList);
|
||||||
|
if (Languages == NULL) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
LangStrings = Languages;
|
LangStrings = Languages;
|
||||||
while (*LangStrings != 0) {
|
while (*LangStrings != 0) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -581,12 +581,18 @@ GluePeCoffLoaderRelocateImage (
|
||||||
// the optional header to verify a desired directory entry is there.
|
// the optional header to verify a desired directory entry is there.
|
||||||
//
|
//
|
||||||
|
|
||||||
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
|
||||||
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
||||||
RelocBaseEnd = PeCoffLoaderImageAddress (
|
RelocBaseEnd = PeCoffLoaderImageAddress (
|
||||||
ImageContext,
|
ImageContext,
|
||||||
RelocDir->VirtualAddress + RelocDir->Size - 1
|
RelocDir->VirtualAddress + RelocDir->Size - 1
|
||||||
);
|
);
|
||||||
|
if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
|
||||||
|
//
|
||||||
|
// If the base start or end address resolved to 0, then fail.
|
||||||
|
//
|
||||||
|
return RETURN_LOAD_ERROR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Set base and end to bypass processing below.
|
// Set base and end to bypass processing below.
|
||||||
|
@ -602,13 +608,21 @@ GluePeCoffLoaderRelocateImage (
|
||||||
// Find the relocation block
|
// Find the relocation block
|
||||||
//
|
//
|
||||||
RelocDir = &Hdr.Te->DataDirectory[0];
|
RelocDir = &Hdr.Te->DataDirectory[0];
|
||||||
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
if (RelocDir->Size > 0) {
|
||||||
ImageContext->ImageAddress +
|
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
||||||
RelocDir->VirtualAddress +
|
ImageContext->ImageAddress +
|
||||||
sizeof(EFI_TE_IMAGE_HEADER) -
|
RelocDir->VirtualAddress +
|
||||||
Hdr.Te->StrippedSize
|
sizeof(EFI_TE_IMAGE_HEADER) -
|
||||||
);
|
Hdr.Te->StrippedSize
|
||||||
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
);
|
||||||
|
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Set base and end to bypass processing below.
|
||||||
|
//
|
||||||
|
RelocBase = NULL;
|
||||||
|
RelocBaseEnd = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -621,6 +635,13 @@ GluePeCoffLoaderRelocateImage (
|
||||||
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
|
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
|
||||||
if (!(ImageContext->IsTeImage)) {
|
if (!(ImageContext->IsTeImage)) {
|
||||||
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
|
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
|
||||||
|
|
||||||
|
if (FixupBase == NULL) {
|
||||||
|
//
|
||||||
|
// If the FixupBase address resolved to 0, then fail.
|
||||||
|
//
|
||||||
|
return RETURN_LOAD_ERROR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
||||||
RelocBase->VirtualAddress +
|
RelocBase->VirtualAddress +
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -152,15 +152,32 @@ GlueMakeTable (
|
||||||
UINT16 WordOfStart;
|
UINT16 WordOfStart;
|
||||||
UINT16 WordOfCount;
|
UINT16 WordOfCount;
|
||||||
|
|
||||||
|
//
|
||||||
for (Index = 1; Index <= 16; Index++) {
|
// TableBits should not be greater than 16.
|
||||||
|
//
|
||||||
|
if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
|
||||||
|
//
|
||||||
|
for (Index = 0; Index <= 16; Index++) {
|
||||||
Count[Index] = 0;
|
Count[Index] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < NumOfChar; Index++) {
|
for (Index = 0; Index < NumOfChar; Index++) {
|
||||||
Count[BitLen[Index]]++;
|
//
|
||||||
|
// Count array index should not be greater than or equal to its size.
|
||||||
|
//
|
||||||
|
if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
|
||||||
|
Count[BitLen[Index]]++;
|
||||||
|
} else {
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Start[0] = 0;
|
||||||
Start[1] = 0;
|
Start[1] = 0;
|
||||||
|
|
||||||
for (Index = 1; Index <= 16; Index++) {
|
for (Index = 1; Index <= 16; Index++) {
|
||||||
|
@ -201,7 +218,7 @@ GlueMakeTable (
|
||||||
for (Char = 0; Char < NumOfChar; Char++) {
|
for (Char = 0; Char < NumOfChar; Char++) {
|
||||||
|
|
||||||
Len = BitLen[Char];
|
Len = BitLen[Char];
|
||||||
if (Len == 0) {
|
if (Len == 0 || Len >= 17) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,14 +237,20 @@ GlueMakeTable (
|
||||||
Index = (UINT16) (Len - TableBits);
|
Index = (UINT16) (Len - TableBits);
|
||||||
|
|
||||||
while (Index != 0) {
|
while (Index != 0) {
|
||||||
if (*Pointer == 0) {
|
//
|
||||||
|
// Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
|
||||||
|
//
|
||||||
|
if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
|
||||||
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
|
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
|
||||||
*Pointer = Avail++;
|
*Pointer = Avail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Index3 & Mask) {
|
//
|
||||||
|
// *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
|
||||||
|
//
|
||||||
|
if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
|
||||||
Pointer = &Sd->mRight[*Pointer];
|
Pointer = &Sd->mRight[*Pointer];
|
||||||
} else {
|
} else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
|
||||||
Pointer = &Sd->mLeft[*Pointer];
|
Pointer = &Sd->mLeft[*Pointer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +351,13 @@ GlueReadPTLen (
|
||||||
//
|
//
|
||||||
Number = (UINT16) GetBits (Sd, nbit);
|
Number = (UINT16) GetBits (Sd, nbit);
|
||||||
|
|
||||||
|
if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
|
||||||
|
//
|
||||||
|
// Fail if Number or nn is greater than size of mPTLen
|
||||||
|
//
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (Number == 0) {
|
if (Number == 0) {
|
||||||
//
|
//
|
||||||
// This represents only Huffman code used
|
// This represents only Huffman code used
|
||||||
|
@ -377,6 +407,12 @@ GlueReadPTLen (
|
||||||
if (Index == Special) {
|
if (Index == Special) {
|
||||||
CharC = (UINT16) GetBits (Sd, 2);
|
CharC = (UINT16) GetBits (Sd, 2);
|
||||||
while ((INT16) (--CharC) >= 0) {
|
while ((INT16) (--CharC) >= 0) {
|
||||||
|
if (Index >= sizeof (Sd->mPTLen)) {
|
||||||
|
//
|
||||||
|
// Fail if Index is greater than or equal to mPTLen
|
||||||
|
//
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
Sd->mPTLen[Index++] = 0;
|
Sd->mPTLen[Index++] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -483,6 +483,9 @@ Returns:
|
||||||
|
|
||||||
do {
|
do {
|
||||||
GuidHob = (EFI_HOB_GUID_TYPE *)GlueGetNextGuidHob (&gEfiPeiPerformanceHobGuid, &HobList);
|
GuidHob = (EFI_HOB_GUID_TYPE *)GlueGetNextGuidHob (&gEfiPeiPerformanceHobGuid, &HobList);
|
||||||
|
if (GuidHob == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
LogHob = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)GET_GUID_HOB_DATA (GuidHob);
|
LogHob = (EFI_HOB_GUID_DATA_PERFORMANCE_LOG *)GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
|
||||||
for (Index = 0; Index < LogHob->NumberOfEntries; Index++) {
|
for (Index = 0; Index < LogHob->NumberOfEntries; Index++) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -52,6 +52,9 @@ GluePreparePackages (
|
||||||
|
|
||||||
HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
|
HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
|
||||||
ASSERT (HiiPackages != NULL);
|
ASSERT (HiiPackages != NULL);
|
||||||
|
if (HiiPackages == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
HiiPackages->GuidId = (EFI_GUID *) Guid;
|
HiiPackages->GuidId = (EFI_GUID *) Guid;
|
||||||
HiiPackages->NumberOfPackages = NumberOfPackages;
|
HiiPackages->NumberOfPackages = NumberOfPackages;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -312,14 +312,32 @@ Returns:
|
||||||
UINT16 NextCode;
|
UINT16 NextCode;
|
||||||
UINT16 Mask;
|
UINT16 Mask;
|
||||||
|
|
||||||
for (Index = 1; Index <= 16; Index++) {
|
//
|
||||||
|
// TableBits should not be greater than 16.
|
||||||
|
//
|
||||||
|
if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
|
||||||
|
//
|
||||||
|
for (Index = 0; Index <= 16; Index++) {
|
||||||
Count[Index] = 0;
|
Count[Index] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Index = 0; Index < NumOfChar; Index++) {
|
for (Index = 0; Index < NumOfChar; Index++) {
|
||||||
Count[BitLen[Index]]++;
|
//
|
||||||
|
// Count array index should not be greater than or equal to its size.
|
||||||
|
//
|
||||||
|
if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
|
||||||
|
Count[BitLen[Index]]++;
|
||||||
|
} else {
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Start[0] = 0;
|
||||||
Start[1] = 0;
|
Start[1] = 0;
|
||||||
|
|
||||||
for (Index = 1; Index <= 16; Index++) {
|
for (Index = 1; Index <= 16; Index++) {
|
||||||
|
@ -358,7 +376,7 @@ Returns:
|
||||||
for (Char = 0; Char < NumOfChar; Char++) {
|
for (Char = 0; Char < NumOfChar; Char++) {
|
||||||
|
|
||||||
Len = BitLen[Char];
|
Len = BitLen[Char];
|
||||||
if (Len == 0) {
|
if (Len == 0 || Len >= 17) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,14 +395,20 @@ Returns:
|
||||||
Index = (UINT16) (Len - TableBits);
|
Index = (UINT16) (Len - TableBits);
|
||||||
|
|
||||||
while (Index != 0) {
|
while (Index != 0) {
|
||||||
if (*Pointer == 0) {
|
//
|
||||||
|
// Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
|
||||||
|
//
|
||||||
|
if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
|
||||||
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
|
Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
|
||||||
*Pointer = Avail++;
|
*Pointer = Avail++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Index3 & Mask) {
|
//
|
||||||
|
// *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
|
||||||
|
//
|
||||||
|
if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
|
||||||
Pointer = &Sd->mRight[*Pointer];
|
Pointer = &Sd->mRight[*Pointer];
|
||||||
} else {
|
} else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
|
||||||
Pointer = &Sd->mLeft[*Pointer];
|
Pointer = &Sd->mLeft[*Pointer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +517,13 @@ Returns:
|
||||||
|
|
||||||
Number = (UINT16) GetBits (Sd, nbit);
|
Number = (UINT16) GetBits (Sd, nbit);
|
||||||
|
|
||||||
|
if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
|
||||||
|
//
|
||||||
|
// Fail if Number or nn is greater than size of mPTLen
|
||||||
|
//
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (Number == 0) {
|
if (Number == 0) {
|
||||||
CharC = (UINT16) GetBits (Sd, nbit);
|
CharC = (UINT16) GetBits (Sd, nbit);
|
||||||
|
|
||||||
|
@ -528,6 +559,12 @@ Returns:
|
||||||
if (Index == Special) {
|
if (Index == Special) {
|
||||||
CharC = (UINT16) GetBits (Sd, 2);
|
CharC = (UINT16) GetBits (Sd, 2);
|
||||||
while ((INT16) (--CharC) >= 0) {
|
while ((INT16) (--CharC) >= 0) {
|
||||||
|
if (Index >= sizeof (Sd->mPTLen)) {
|
||||||
|
//
|
||||||
|
// Fail if Index is greater than or equal to mPTLen
|
||||||
|
//
|
||||||
|
return (UINT16) BAD_TABLE;
|
||||||
|
}
|
||||||
Sd->mPTLen[Index++] = 0;
|
Sd->mPTLen[Index++] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -785,12 +785,18 @@ Returns:
|
||||||
// the optional header to verify a desired directory entry is there.
|
// the optional header to verify a desired directory entry is there.
|
||||||
//
|
//
|
||||||
|
|
||||||
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
|
if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
|
||||||
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
|
||||||
RelocBaseEnd = PeCoffLoaderImageAddress (
|
RelocBaseEnd = PeCoffLoaderImageAddress (
|
||||||
ImageContext,
|
ImageContext,
|
||||||
RelocDir->VirtualAddress + RelocDir->Size - 1
|
RelocDir->VirtualAddress + RelocDir->Size - 1
|
||||||
);
|
);
|
||||||
|
if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
|
||||||
|
//
|
||||||
|
// If the base start or end address resolved to 0, then fail.
|
||||||
|
//
|
||||||
|
return EFI_LOAD_ERROR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Set base and end to bypass processing below.
|
// Set base and end to bypass processing below.
|
||||||
|
@ -806,13 +812,21 @@ Returns:
|
||||||
// Find the relocation block
|
// Find the relocation block
|
||||||
//
|
//
|
||||||
RelocDir = &Hdr.Te->DataDirectory[0];
|
RelocDir = &Hdr.Te->DataDirectory[0];
|
||||||
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
if (RelocDir->Size > 0) {
|
||||||
ImageContext->ImageAddress +
|
RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
|
||||||
RelocDir->VirtualAddress +
|
ImageContext->ImageAddress +
|
||||||
sizeof(EFI_TE_IMAGE_HEADER) -
|
RelocDir->VirtualAddress +
|
||||||
Hdr.Te->StrippedSize
|
sizeof(EFI_TE_IMAGE_HEADER) -
|
||||||
);
|
Hdr.Te->StrippedSize
|
||||||
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
);
|
||||||
|
RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Set base and end to bypass processing below.
|
||||||
|
//
|
||||||
|
RelocBase = NULL;
|
||||||
|
RelocBaseEnd = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -825,6 +839,13 @@ Returns:
|
||||||
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
|
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
|
||||||
if (!(ImageContext->IsTeImage)) {
|
if (!(ImageContext->IsTeImage)) {
|
||||||
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
|
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
|
||||||
|
|
||||||
|
if (FixupBase == NULL) {
|
||||||
|
//
|
||||||
|
// If the FixupBase address resolved to 0, then fail.
|
||||||
|
//
|
||||||
|
return EFI_LOAD_ERROR;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
||||||
RelocBase->VirtualAddress +
|
RelocBase->VirtualAddress +
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -66,9 +66,9 @@ Returns:
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Put break point in module that contained the error.
|
// Put dead loop in module that contained the error.
|
||||||
//
|
//
|
||||||
EFI_BREAKPOINT ();
|
EFI_DEADLOOP ();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -947,6 +947,7 @@ Returns:
|
||||||
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
|
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
|
||||||
|
|
||||||
ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
|
ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
|
||||||
|
ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);
|
||||||
|
|
||||||
return ReturnReg.Status;
|
return ReturnReg.Status;
|
||||||
|
|
||||||
|
@ -1015,6 +1016,7 @@ Returns:
|
||||||
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
|
EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
|
||||||
|
|
||||||
ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
|
ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
|
||||||
|
ASSERT (ReturnReg.Status == EFI_SAL_SUCCESS);
|
||||||
|
|
||||||
return ReturnReg.Status;
|
return ReturnReg.Status;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -289,8 +289,7 @@ Returns:
|
||||||
&mPpiListStatusCode
|
&mPpiListStatusCode
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
EFI_BREAKPOINT ();
|
EFI_DEADLOOP ();
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Publish a GUIDed HOB that contains a pointer to the status code PPI
|
// Publish a GUIDed HOB that contains a pointer to the status code PPI
|
||||||
|
@ -306,8 +305,7 @@ Returns:
|
||||||
sizeof (VOID *)
|
sizeof (VOID *)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
EFI_BREAKPOINT ();
|
EFI_DEADLOOP ();
|
||||||
return ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -2073,8 +2073,8 @@ Returns:
|
||||||
{
|
{
|
||||||
UINTN Current;
|
UINTN Current;
|
||||||
|
|
||||||
ASSERT (Table);
|
ASSERT (Table != NULL);
|
||||||
ASSERT (Token);
|
ASSERT (Token != NULL);
|
||||||
|
|
||||||
Current = 0;
|
Current = 0;
|
||||||
*Token = 0;
|
*Token = 0;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -124,6 +124,7 @@ Returns:
|
||||||
// Locate the HOB that contains the PPI structure for the memory journal
|
// Locate the HOB that contains the PPI structure for the memory journal
|
||||||
// We don't check for more than one.
|
// We don't check for more than one.
|
||||||
//
|
//
|
||||||
|
StatusCodeMemoryPpi = NULL;
|
||||||
EfiLibGetSystemConfigurationTable (
|
EfiLibGetSystemConfigurationTable (
|
||||||
&gEfiHobListGuid,
|
&gEfiHobListGuid,
|
||||||
&HobList
|
&HobList
|
||||||
|
@ -134,7 +135,7 @@ Returns:
|
||||||
(VOID **) &StatusCodeMemoryPpi,
|
(VOID **) &StatusCodeMemoryPpi,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status) || (StatusCodeMemoryPpi == NULL)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*++
|
/*++
|
||||||
|
|
||||||
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -133,11 +133,11 @@ Returns:
|
||||||
// is connected.
|
// is connected.
|
||||||
//
|
//
|
||||||
mPeiReportStatusCode = NULL;
|
mPeiReportStatusCode = NULL;
|
||||||
|
Pointer = NULL;
|
||||||
Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
|
Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);
|
Status = GetNextGuidHob (&HobList, &gEfiStatusCodeRuntimeProtocolGuid, &Pointer, NULL);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status) && (Pointer != NULL)) {
|
||||||
mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);
|
mPeiReportStatusCode = (EFI_REPORT_STATUS_CODE) (*(UINTN *) Pointer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue