From: "Gao, Liming" <liming.gao@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH v2] MdeModulePkg/DebugLib: Print partial when format string is too long
Date: Mon, 15 Jan 2018 05:14:12 +0000 [thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1A45DD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20180115035936.118780-1-ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
>-----Original Message-----
>From: Ni, Ruiyu
>Sent: Monday, January 15, 2018 12:00 PM
>To: edk2-devel@lists.01.org
>Cc: Gao, Liming <liming.gao@intel.com>
>Subject: [PATCH v2] MdeModulePkg/DebugLib: Print partial when format
>string is too long
>
>Today's implementation prints nothing when the format string cannot
>fit in the report status extended data buffer.
>It confuses user.
>The patch changes to print partial message by truncating the format
>string when it's too long.
>
>The missing enhancement is the extended data buffer only reserves 96
>bytes for the var-args. When the format string is not very long but
>contains 13 %lx or %p, the var-args buffer is too small. Today's
>implementation prints nothing for this case.
>This patch doesn't change such behavior.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>---
> .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 11 +++++++--
>--
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
>diff --git
>a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>index 163d530ae5..16a1d206fb 100644
>--- a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>+++
>b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c
>@@ -4,7 +4,7 @@
> Note that if the debug message length is larger than the maximum allowable
> record length, then the debug message will be ignored directly.
>
>- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
>+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> This program and the accompanying materials
> are licensed and made available under the terms and conditions of the BSD
>License
> which accompanies this distribution. The full text of the license may be
>found at
>@@ -96,7 +96,7 @@ DebugPrint (
> // If the TotalSize is larger than the maximum record size, then return
> //
> if (TotalSize > sizeof (Buffer)) {
>- return;
>+ TotalSize = sizeof (Buffer);
> }
>
> //
>@@ -113,9 +113,12 @@ DebugPrint (
> FormatString = (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12);
>
> //
>- // Copy the Format string into the record
>+ // Copy the Format string into the record. It will be truncated if it's too long.
> //
>- AsciiStrCpyS (FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) +
>12 * sizeof(UINT64)), Format);
>+ AsciiStrnCpyS (
>+ FormatString, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 *
>sizeof(UINT64)),
>+ Format, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 *
>sizeof(UINT64)) - 1
>+ );
>
> //
> // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for
>variable arguments
>--
>2.15.1.windows.2
prev parent reply other threads:[~2018-01-15 5:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 3:59 [PATCH v2] MdeModulePkg/DebugLib: Print partial when format string is too long Ruiyu Ni
2018-01-15 5:14 ` Gao, Liming [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E1A45DD@SHSMSX104.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox