]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
IntelFrameworkModulePkg/DebugLib: Fix string copy issue
[mirror_edk2.git] / IntelFrameworkModulePkg / Library / PeiDxeDebugLibReportStatusCode / DebugLib.c
index 3f3778d84a07d117e5714bc2a50dd14b8e56a16f..1840b6d68313399fd2da301cbefdae2059c25863 100644 (file)
@@ -5,13 +5,7 @@
   record length, then the debug message will be ignored directly.\r
 \r
   Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -156,7 +150,7 @@ DebugPrintMarker (
   FormatString          = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);\r
 \r
   //\r
-  // Copy the Format string into the record\r
+  // Copy the Format string into the record. It will be truncated if it's too long.\r
   //\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
@@ -164,7 +158,7 @@ DebugPrintMarker (
   // 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
+  AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, DestBufferSize / sizeof (CHAR8) - 1);\r
 \r
   //\r
   // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r