From nobody Sun May 5 10:36:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41115+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41115+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558424999; cv=none; d=zoho.com; s=zohoarc; b=Wvh36hrjeU/rGuzDoOIDo5gDoBYeJroq1bg7e94GeVI9AI8Nv3mkmg4ZsTXI4mutGA0BumU9+dD+vhccMXLS3fgTnNWZh/L1LSmWh4BGwm90jZRyvo/oxia0GPoPILM9EnCuAkVXVwHZpWU47oMB2pPIGOLyd3yq8tIJYGMIa68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558424999; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=gyle4BjNCTflcvTbaMMGbuPRc1w8VX+vNhanWtcpo6Y=; b=PbJftFbFuSyIunjJF4046PQLg9Xz8ApvdXOrDZDa+GnsCRZEcuayeY3RBmU2qWbQL51EaHlfNzsGoFlEK3vzHaeeiqMA9JYzSarcIPD09LU5EAxeoDX3KzcMVJvONgslhabxwmUWkTnQqm0cWqO0N8m1IFSDsxP+QSD3D8YRxOk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41115+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558424999955328.48910970912505; Tue, 21 May 2019 00:49:59 -0700 (PDT) Return-Path: X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by groups.io with SMTP; Tue, 21 May 2019 00:49:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 00:49:58 -0700 X-ExtLoop1: 1 X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga006.fm.intel.com with ESMTP; 21 May 2019 00:49:57 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Liming Gao , Hao A Wu Subject: [edk2-devel] [PATCH] IntelFrameworkModulePkg/DebugLib: Fix string copy issue Date: Tue, 21 May 2019 15:49:52 +0800 Message-Id: <20190521074952.38376-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558424999; bh=z+S0X1mpfqtSr6T5/ibY4GgBGLnYQjQiVkDbJ7fmL1w=; h=Cc:Date:From:Reply-To:Subject:To; b=qGd9Yq81ZOxP9DNgl/ZmB7mjiQHbJK+NO29tqJCkPs66gCmqQHAgtdy/uZ9ZkggNCnV UlIeFBOig4AxrZmxQYBUUmxtvaUvNY+PRFXlFEsGs/YyCslxrAlXWyHXjo5cd4ZxI3qow hkvubZsIDTicfbj++SOwv90lEcgpwtJVHbg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1826 There is a bug to use AsciiStrCpyS to copy a truncated string. If would cause an assert because the truncated length is always less than the source string length. It should use the AsciiStrnCpyS instead. Cc: Liming Gao Cc: Hao A Wu Signed-off-by: Zhichao Gao Reviewed-by: Hao A Wu Reviewed-by: Liming Gao --- .../Library/PeiDxeDebugLibReportStatusCode/DebugLib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode= /DebugLib.c b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCod= e/DebugLib.c index e92601f89e..1840b6d683 100644 --- a/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugL= ib.c +++ b/IntelFrameworkModulePkg/Library/PeiDxeDebugLibReportStatusCode/DebugL= ib.c @@ -150,7 +150,7 @@ DebugPrintMarker ( 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. // // According to the content structure of Buffer shown above, the size of // the FormatString buffer is the size of Buffer minus the Padding @@ -158,7 +158,7 @@ DebugPrintMarker ( // variable arguments (12 * sizeof (UINT64)). // DestBufferSize =3D sizeof (Buffer) - 4 - sizeof (EFI_DEBUG_INFO) - 12 * = sizeof (UINT64); - AsciiStrCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format); + AsciiStrnCpyS (FormatString, DestBufferSize / sizeof (CHAR8), Format, De= stBufferSize / sizeof (CHAR8) - 1); =20 // // The first 12 * sizeof (UINT64) bytes following EFI_DEBUG_INFO are for= variable arguments --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41115): https://edk2.groups.io/g/devel/message/41115 Mute This Topic: https://groups.io/mt/31694427/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-