From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Void lookup limit of 2 exceeded) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B6DA0222DDBE6 for ; Sun, 14 Jan 2018 21:08:57 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2018 21:14:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,362,1511856000"; d="scan'208";a="10054192" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 14 Jan 2018 21:14:15 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 14 Jan 2018 21:14:15 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 14 Jan 2018 21:14:14 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Mon, 15 Jan 2018 13:14:12 +0800 From: "Gao, Liming" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH v2] MdeModulePkg/DebugLib: Print partial when format string is too long Thread-Index: AQHTjbVJimHq80VRBEul17EVYFg06aN0Y+7A Date: Mon, 15 Jan 2018 05:14:12 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1A45DD@SHSMSX104.ccr.corp.intel.com> References: <20180115035936.118780-1-ruiyu.ni@intel.com> In-Reply-To: <20180115035936.118780-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdeModulePkg/DebugLib: Print partial when format string is too long X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jan 2018 05:08:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Ni, Ruiyu >Sent: Monday, January 15, 2018 12:00 PM >To: edk2-devel@lists.01.org >Cc: Gao, Liming >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 >Cc: Liming Gao >--- > .../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 allowa= ble > record length, then the debug message will be ignored directly. > >- Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
>+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the B= SD >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 =3D sizeof (Buffer); > } > > // >@@ -113,9 +113,12 @@ DebugPrint ( > FormatString =3D (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 fo= r >variable arguments >-- >2.15.1.windows.2