]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFrameworkModulePkg PeiDxeDebugLib: Use safe string functions
authorHao Wu <hao.a.wu@intel.com>
Tue, 30 Jun 2015 06:26:20 +0000 (06:26 +0000)
committerhwu1225 <hwu1225@Edk2>
Tue, 30 Jun 2015 06:26:20 +0000 (06:26 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17734 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c

index 68c1a5570b9e59dddc8baa69060e0b8c4e9b6c42..cfdd2f50d51e0dc6ecfad5f5cde1daf53d78a2d0 100644 (file)
@@ -56,6 +56,7 @@ DebugPrint (
   UINT64          Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)) + 1];\r
   EFI_DEBUG_INFO  *DebugInfo;\r
   UINTN           TotalSize;\r
+  UINTN           DestBufferSize;\r
   VA_LIST         VaListMarker;\r
   BASE_LIST       BaseListMarker;\r
   CHAR8           *FormatString;\r
@@ -115,7 +116,13 @@ DebugPrint (
   //\r
   // Copy the Format string into the record\r
   //\r
-  AsciiStrCpy (FormatString, Format);\r
+  // According to the content structure of Buffer shown above, the size of\r
+  // the FormatString buffer is the size of Buffer minus the Padding\r
+  // (4 bytes), minus the size of EFI_DEBUG_INFO, minus the size of\r
+  // variable arguments (12 * sizeof (UINT64)).\r
+  //\r
+  DestBufferSize = sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * sizeof (UINT64);\r
+  AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format);\r
 \r
   //\r
   // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r