Revision: 17309 http://sourceforge.net/p/edk2/code/17309 Author: oliviermartin Date: 2015-05-05 15:51:44 +0000 (Tue, 05 May 2015) Log Message: ----------- EmbeddedPkg: do not ASSERT() on valid external input
Since ASSERT()s are enabled even on all ArmPlatformPkg RELEASE builds, ASSERT()ing on a valid FDT header will crash the firmware if the user selects an incorrect file. Since ASSERT() is meant to catch internal inconsistencies in the firmware, its use here is inappropriate. Instead, handle it as a normal error condition. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org> Reviewed-by: Olivier Martin <olivier.mar...@arm.com> Modified Paths: -------------- trunk/edk2/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c Modified: trunk/edk2/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c =================================================================== --- trunk/edk2/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c 2015-05-05 15:48:59 UTC (rev 17308) +++ trunk/edk2/EmbeddedPkg/Drivers/FdtPlatformDxe/FdtPlatform.c 2015-05-05 15:51:44 UTC (rev 17309) @@ -94,15 +94,16 @@ goto Error; } - // Check the FDT header is valid. We only make this check in DEBUG mode in - // case the FDT header change on production device and this ASSERT() becomes - // not valid. - ASSERT (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) == 0); - // - // Ensure the Size of the Device Tree is smaller than the size of the read file + // Ensure that the FDT header is valid and that the Size of the Device Tree + // is smaller than the size of the read file // - ASSERT ((UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) <= FdtBlobSize); + if (fdt_check_header ((VOID*)(UINTN)FdtBlobBase) != 0 || + (UINTN)fdt_totalsize ((VOID*)(UINTN)FdtBlobBase) > FdtBlobSize) { + DEBUG ((EFI_D_ERROR, "InstallFdt() - loaded FDT binary image seems corrupt\n")); + Status = EFI_LOAD_ERROR; + goto Error; + } // // Store the FDT as Runtime Service Data to prevent the Kernel from ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits