From b4c222655c8182febba890019367609ac278b1ba Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Fri, 12 Dec 2014 19:13:04 +0000 Subject: ArmPlatformPkg/Bds: Test if OptionalData is NULL before using it Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16515 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPlatformPkg/Bds/BootOption.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ArmPlatformPkg/Bds/BootOption.c') diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c index 5712d2ccb4..80982222e1 100644 --- a/ArmPlatformPkg/Bds/BootOption.c +++ b/ArmPlatformPkg/Bds/BootOption.c @@ -221,6 +221,8 @@ BootOptionSetFields ( WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE); WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType); + // OptionalData should have been initialized by the caller of this function + ASSERT (OptionalData != NULL); BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)OptionalData; SrcLinuxArguments = &(BootArguments->LinuxArguments); DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments; @@ -237,7 +239,9 @@ BootOptionSetFields ( CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize); } } else { - CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize); + if (OptionalData != NULL) { + CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize); + } } BootOption->OptionalDataSize = OptionalDataSize; -- cgit v1.2.3