From 038a15e2b2ec5533270e2a723767eb0a698deaa0 Mon Sep 17 00:00:00 2001 From: Abdul Lateef Attar Date: Thu, 21 Nov 2024 08:18:20 +0000 Subject: [PATCH] AmdPlatformPkg/DynamicTables: Fix Coverity issue Fix for coverity reported issue on ConfigurationManagerDxe. Fix the possible integer overflow. Fix the typecast of const to non-const. Cc: Abner Chang Cc: Paul Grimes Signed-off-by: Abdul Lateef Attar --- .../ConfigurationManagerDxe/ConfigurationManager.c | 1 - .../DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c index 219512edb09..cb0135de819 100755 --- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c @@ -175,7 +175,6 @@ EDKII_PLATFORM_REPOSITORY_INFO mAmdPlatformRepositoryInfo = { /** A structure describing the configuration manager protocol interface. */ STATIC -CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL mAmdPlatformConfigManagerProtocol = { CREATE_REVISION (1, 0), AmdPlatformGetObject, diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c index 13ceba08607..70fd848790d 100644 --- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c +++ b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c @@ -32,6 +32,10 @@ HandleCmObject ( IN OUT CM_OBJ_DESCRIPTOR *CONST CmObjectDesc ) { + if ((ObjectSize > MAX_UINT32) || (ObjectCount > MAX_UINT32)) { + return EFI_INVALID_PARAMETER; + } + CmObjectDesc->ObjectId = CmObjectId; CmObjectDesc->Size = (UINT32)ObjectSize; CmObjectDesc->Data = (VOID *)Object;