Note that if the debug message length is larger than the maximum allowable\r
record length, then the debug message will be ignored directly.\r
\r
- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2018, 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
// If the TotalSize is larger than the maximum record size, then return\r
//\r
if (TotalSize > sizeof (Buffer)) {\r
- return;\r
+ TotalSize = sizeof (Buffer);\r
}\r
\r
//\r
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
- AsciiStrCpyS (FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)), Format);\r
+ AsciiStrnCpyS (\r
+ FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)),\r
+ Format, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * sizeof(UINT64)) - 1\r
+ );\r
\r
//\r
// The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for variable arguments\r