From nobody Sun May 5 09:41:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1515641759378216.17597844712418; Wed, 10 Jan 2018 19:35:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E21C4222A54DB; Wed, 10 Jan 2018 19:30:43 -0800 (PST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 928C02220D202 for ; Wed, 10 Jan 2018 19:30:42 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jan 2018 19:35:55 -0800 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.19]) by orsmga004.jf.intel.com with ESMTP; 10 Jan 2018 19:35:54 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,343,1511856000"; d="scan'208";a="165842980" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Thu, 11 Jan 2018 11:35:52 +0800 Message-Id: <20180111033552.46800-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [edk2] [PATCH] 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: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 --- .../PeiDxeDebugLibReportStatusCode/DebugLib.c | 21 +++++++----------= ---- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c= b/MdeModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugLib.c index 163d530ae5..785e231cf2 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 allowab= le record length, then the debug message will be ignored directly. =20 - 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 BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -55,7 +55,6 @@ DebugPrint ( { UINT64 Buffer[(EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64))= + 1]; EFI_DEBUG_INFO *DebugInfo; - UINTN TotalSize; VA_LIST VaListMarker; BASE_LIST BaseListMarker; CHAR8 *FormatString; @@ -74,7 +73,6 @@ DebugPrint ( } =20 // - // Compute the total size of the record. // Note that the passing-in format string and variable parameters will b= e constructed to=20 // the following layout: // @@ -90,14 +88,6 @@ DebugPrint ( // | Format String | // |------------------------|<- (UINT8 *)Buffer + sizeof= (Buffer) // - TotalSize =3D 4 + sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + Ascii= StrSize (Format); - - // - // If the TotalSize is larger than the maximum record size, then return - // - if (TotalSize > sizeof (Buffer)) { - return; - } =20 // // Fill in EFI_DEBUG_INFO @@ -113,9 +103,12 @@ DebugPrint ( FormatString =3D (CHAR8 *)((UINT64 *)(DebugInfo + 1) + 12); =20 // - // 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 * size= of(UINT64)), + Format, sizeof(Buffer) - (4 + sizeof(EFI_DEBUG_INFO) + 12 * size= of(UINT64)) - 1 + ); =20 // // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for= variable arguments @@ -223,7 +216,7 @@ DebugPrint ( NULL, &gEfiStatusCodeDataTypeDebugGuid, DebugInfo, - TotalSize + sizeof (Buffer) ); } =20 --=20 2.15.1.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel