1. Rollback the changing on replacing MAX_EXTENDED_DATA_SIZE by EFI_STATUS_CODE_DATA_MAX_SIZE,

use MAX_EXTENDED_DATA_SIZE as before.
2. Use DEBUG error message instead of ASSERT(FASLE) when extended data is too large
3. Expand 1 for buffer array size to avoid potential issue.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11084 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2010-11-23 07:51:00 +00:00
parent 7b78853921
commit 8185265e69
2 changed files with 10 additions and 3 deletions

View File

@ -28,6 +28,12 @@
#include <Guid/StatusCodeDataTypeDebug.h> #include <Guid/StatusCodeDataTypeDebug.h>
#include <Protocol/StatusCode.h> #include <Protocol/StatusCode.h>
//
// Define the maximum extended data size that is supported when a status code is
// reported at TPL_HIGH_LEVEL.
//
#define MAX_EXTENDED_DATA_SIZE 0x200
EFI_REPORT_STATUS_CODE mReportStatusCode = NULL; EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;
/** /**
@ -488,7 +494,7 @@ ReportStatusCodeEx (
EFI_STATUS Status; EFI_STATUS Status;
EFI_STATUS_CODE_DATA *StatusCodeData; EFI_STATUS_CODE_DATA *StatusCodeData;
EFI_TPL Tpl; EFI_TPL Tpl;
UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; UINT64 Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1];
ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0))); ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
@ -515,12 +521,12 @@ ReportStatusCodeEx (
// //
// If a buffer could not be allocated, then see if the local variable Buffer can be used // If a buffer could not be allocated, then see if the local variable Buffer can be used
// //
if (ExtendedDataSize > (EFI_STATUS_CODE_DATA_MAX_SIZE - sizeof (EFI_STATUS_CODE_DATA))) { if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
// //
// The local variable Buffer not large enough to hold the extended data associated // The local variable Buffer not large enough to hold the extended data associated
// with the status code being reported. // with the status code being reported.
// //
ASSERT (FALSE); DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;

View File

@ -394,6 +394,7 @@ ReportStatusCodeEx (
ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) { if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {
DEBUG ((EFI_D_ERROR, "Status code extended data is too large to be reported!\n"));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }