From: vanjeff Date: Tue, 23 Nov 2010 07:50:31 +0000 (+0000) Subject: 1. Rollback the changing on replacing MAX_EXTENDED_DATA_SIZE by EFI_STATUS_CODE_DATA_... X-Git-Tag: edk2-stable201903~15386 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=7b788539217bf9729be00facd66f62bc17091a6e 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@11083 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c index 06bdd54583..ce843cc47f 100644 --- a/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c @@ -25,6 +25,12 @@ #include #include +// +// 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_STATUS_CODE_PROTOCOL *mReportStatusCodeLibStatusCodeProtocol = NULL; /** @@ -485,7 +491,7 @@ ReportStatusCodeEx ( EFI_STATUS Status; EFI_STATUS_CODE_DATA *StatusCodeData; 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))); @@ -512,12 +518,12 @@ ReportStatusCodeEx ( // // 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 // 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; } StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer; diff --git a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c index 70737ba4f6..d41d4e981d 100644 --- a/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c @@ -23,6 +23,11 @@ #include #include +// +// Define the maximum extended data size that is supported in the PEI phase +// +#define MAX_EXTENDED_DATA_SIZE 0x200 + /** Internal worker function that reports a status code through the PEI Status Code Service or OEM Hook Status Code Library. @@ -453,7 +458,7 @@ ReportStatusCodeEx ( ) { EFI_STATUS_CODE_DATA *StatusCodeData; - UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)]; + UINT64 Buffer[(MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)) + 1]; // // If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT(). @@ -464,12 +469,12 @@ ReportStatusCodeEx ( // ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0))); - 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 // 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; } StatusCodeData = (EFI_STATUS_CODE_DATA *) Buffer;