From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.122]) by mx.groups.io with SMTP id smtpd.web10.2788.1590025543311569555 for ; Wed, 20 May 2020 18:45:43 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@microsoft.com header.s=selector2 header.b=hEl16BfV; spf=pass (domain: microsoft.com, ip: 40.107.236.122, mailfrom: bret.barkelew@microsoft.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fptWEWcj6fHjcuiehRADJei7WCDGBmlW7zrrmZtoJF66KDDhDtTEApzDA2yXz9YNWULkOZrPZnbh7ZWOe4QkYejsRWsSBfx4CyD/KLiHnjAfrGck3b/FnqEniprXZ6VywS0FxRrOZnqHsVeVigX3T5N7VYbzyLe1FZefZ/lB+FuSVZDlys3ySV9kOD7ggEuK6peWqacOM2dlkMyLaU+T86ZlEPYjXeu6yUsqy5rXVKmxfM72yvoifgoJa7cAfJybVYeWzXr2TqnMMvGC+ldY1A/KGvj+OiT9Aw0ybf7/LlBC/E4SEBf9yNpzadxkYGycw7O4e9mmOebIS1lPPQI3Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U6zatVCmIx8vqCE9rB5KCpykXZQ0a0M+iT9On3bljC4=; b=fIuEAWxEvuuruANgO76Gh5GS3ISDcYmcUcaDYdylbf7szTzz1ZidCZMCDO+Vsq1XMYeWIn8TCe5OAVnbXTaXPYe7/5SJQ5uHVf9WxFOphs6Z+KWvb59a6c+cWvZbQ12AaoqnM7s8aAWAE/Fc7FfUDY9psGNZV1gvx6KhZa3XLhV3xUK3IR89ca6ffSeVZ5gA5WwndC1UxmrJso8N/c5xi85z+CTaUPkBBnvmGeR74CPG4FcORpWX44t+AxO+bguS2pkl0yNVLtZIUMWjv5bMKcCe83691uz9f6kbHu6rGcwIEolKLETu0eeNpvTXpR/7VOjW0sFFcRXH7prVwiflpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U6zatVCmIx8vqCE9rB5KCpykXZQ0a0M+iT9On3bljC4=; b=hEl16BfVFXn/IZKwn5lrELlq+r2Bqgdn8yeg+LZm1mLpEx55MYnn/sCDDyL+xpl855yGWfVP+KnhUzt/Spuvm8YYQd3KTbiWxyNXcqpzdRk6DvawRMyAKhIgf8hyxcH/ZugDyV+P9XBBXN8o+unt4UPDxXSeMrGwGqnDLK34Ams= Received: from CY4PR21MB0743.namprd21.prod.outlook.com (2603:10b6:903:b2::9) by CY4PR21MB0470.namprd21.prod.outlook.com (2603:10b6:903:db::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.5; Thu, 21 May 2020 01:45:41 +0000 Received: from CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd]) by CY4PR21MB0743.namprd21.prod.outlook.com ([fe80::f112:82fb:d4fd:f7dd%12]) with mapi id 15.20.3045.005; Thu, 21 May 2020 01:45:41 +0000 From: "Bret Barkelew" To: "michael.kubacki@outlook.com" , "devel@edk2.groups.io" CC: Sean Brogan , liming.gao , "Kinney, Michael D" Subject: Re: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS() Thread-Topic: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultReportLib: Use AsciiStrnCpyS() Thread-Index: AQHWLw8953MqdDP2/EeOYwOI27QuZqixxOIy Date: Thu, 21 May 2020 01:45:41 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-05-21T01:45:26.8425131Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Privileged authentication-results: outlook.com; dkim=none (message not signed) header.d=none;outlook.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [71.212.144.72] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 9584d02f-245b-4b01-ff08-08d7fd28ab6e x-ms-traffictypediagnostic: CY4PR21MB0470: x-ms-exchange-transport-forked: True x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4303; x-forefront-prvs: 041032FF37 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: y79JW7Wb/+rbZz3KVlWuaDymQNa4uVdNSZbvqJkLdgY4ASUozL7qshiMfqhpomFKQjkcd3WttbY83+DZ2njAETaBlC9iGT5kfoODXdMzdHPLV2M7CGEtwOHobCf1YJcHB1e+k9iS6ndD94/Oi4JzKAQrtZiknE4qHVGaxw3PWgcTJeStstDHrWZZLVAzVgz0r7ZJFkWMqJvhqg9rlFKkL8f64pmEzQ4SEES07GlTPg29kF5hbyky2KwoqujSCvgl5QMdYFOdcu8jBIBJ09bTfEWBcsMRL1g/skQOlD27whBZ1Ku5SjZxsPCc1t2hiMfEmFqro8s3dq9h2yrF3+ENG0qePy9UCE8j5OoNzqrX1ScQ3dYTGmqaLDv6Z/V1aJEcN6mwrimEUmy2rewWxySYoMigrdWZ1F4qqsaFRFTmYYGknBbgMHfYtmmy6CEiwuq3I2LEwUgzskcf72lcq4LbDA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR21MB0743.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(396003)(346002)(376002)(39860400002)(136003)(366004)(53546011)(186003)(33656002)(8990500004)(5660300002)(71200400001)(7696005)(478600001)(2906002)(6506007)(8936002)(82960400001)(82950400001)(26005)(110136005)(54906003)(66946007)(64756008)(10290500003)(76116006)(66556008)(52536014)(66476007)(86362001)(55016002)(91956017)(9686003)(316002)(66446008)(8676002)(4326008)(213903007);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: yfU5ESmWevUHVc/m5spPN4Sgj83aikUpzPoMtNTogRLyGsC/ASFKAZbV7InyjDfKfEgY1H2acNJLWB10VqAlwBhbyBGiYoqMc8I3W3hgH52YkNeDleXLMh7k9EpvSQznrfqUP58ll7YPUWPLBhTliYDbH5DRvFdOFTRjtXEcJEwvSAJkTZlEdw6kDAZoNL8ub2DlYP558k+MDjc2nElhxPzAxVMC3E1YIpx8PbCK7PCewn1/BKVQlkF3t4KR44hPyXUBWfFl25XguS3QKjCJjd+4hPs8D5UvHLqHFQ0OIMduAE0D78Fbx7wFKoGJ/0bFaxOA0DYfWY/42hxsuUTxwZ6Wa5ebI4ueUluq7lD7Z+lJrt/FeYhl/JnU0/4vPi7GXLsvAMV+9Dsx8iNrmjd5/LwgjBbgHDsgDZNzVLgqWBahXqsETAX66jnwIbhjTZziRv0X3QoDBurdVJxlZ5lfcJjAPN/td1DZtnzEkdizDuI= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9584d02f-245b-4b01-ff08-08d7fd28ab6e X-MS-Exchange-CrossTenant-originalarrivaltime: 21 May 2020 01:45:41.1812 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CFuyjnp8uRM+B0LzGLkbktmlXrmixdicVGpq3Va+4UBEmGkOdGWjQ0Bf4T2+jeOOqEHcG9qgDr54ywyaeTJnKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0470 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR21MB0743F0BC6EB5249DC06E953BEFB70CY4PR21MB0743namp_" --_000_CY4PR21MB0743F0BC6EB5249DC06E953BEFB70CY4PR21MB0743namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bret Barkelew - Bret ________________________________ From: michael.kubacki@outlook.com Sent: Wednesday, May 20, 2020 6:28:40 PM To: devel@edk2.groups.io Cc: Bret Barkelew ; Sean Brogan ; liming.gao ; Kinney, Michael D Subject: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResultRepor= tLib: Use AsciiStrnCpyS() From: Michael Kubacki REF:https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbug= zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2721&data=3D02%7C01%7CBret.Ba= rkelew%40microsoft.com%7C3df7de73c045465745a708d7fd265f00%7C72f988bf86f141a= f91ab2d7cd011db47%7C1%7C0%7C637256213561542812&sdata=3Dd28c2VOQ%2FCn53u= FUGpddqFtL3lmX9Kir7mvKYm7%2BYEw%3D&reserved=3D0 The ReportOutput() function in UnitTestResultReportLib copies characters from a function input buffer to an intermediate local buffer in fixed size chunks of the maximum size of the intermediate buffer. The implementation currently calls AsciiStrCpyS() which will ASSERT on an error. This commit changes the call to AsciiStrnCpyS() to avoid the ASSERT which is not expected in the usage of the string copy in this implementation. Cc: Bret Barkelew Cc: Sean Brogan Cc: Liming Gao Cc: Michael D Kinney Signed-off-by: Michael Kubacki --- UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportL= ibConOut.c | 2 +- UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportL= ibDebugLib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestR= esultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportL= ib/UnitTestResultReportLibConOut.c index 139360ee1657..cfb0c5972bd1 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibConOut.c +++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibConOut.c @@ -42,7 +42,7 @@ ReportOutput ( Length =3D AsciiStrLen (Output); for (Index =3D 0; Index < Length; Index +=3D (sizeof (AsciiString) - 1))= { - AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]); + AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], size= of (AsciiString) - 1); ReportPrint ("%a", AsciiString); } } diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestR= esultReportLibDebugLib.c b/UnitTestFrameworkPkg/Library/UnitTestResultRepor= tLib/UnitTestResultReportLibDebugLib.c index 743aad2958a7..1402d0ef83e2 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibDebugLib.c +++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibDebugLib.c @@ -41,7 +41,7 @@ ReportOutput ( Length =3D AsciiStrLen (Output); for (Index =3D 0; Index < Length; Index +=3D (sizeof (AsciiString) - 1))= { - AsciiStrCpyS (AsciiString, sizeof (AsciiString), &Output[Index]); + AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &Output[Index], size= of (AsciiString) - 1); DEBUG ((DEBUG_INFO, AsciiString)); } } -- 2.16.3.windows.1 --_000_CY4PR21MB0743F0BC6EB5249DC06E953BEFB70CY4PR21MB0743namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Reviewed-by: Bret Barkelew <bret.barkelew@microso= ft.com>

 

- Bret

 


From: michael.kubacki@outlo= ok.com <michael.kubacki@outlook.com>
Sent: Wednesday, May 20, 2020 6:28:40 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>; Sean Brogan &= lt;sean.brogan@microsoft.com>; liming.gao <liming.gao@intel.com>; = Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [EXTERNAL] [PATCH v1 1/1] UnitTestFrameworkPkg/UnitTestResu= ltReportLib: Use AsciiStrnCpyS()
 
From: Michael Kubacki <michael.kubacki@microsof= t.com>

REF:https://nam06.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fbug= zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2721&amp;data=3D02%7C01%7CBre= t.Barkelew%40microsoft.com%7C3df7de73c045465745a708d7fd265f00%7C72f988bf86f= 141af91ab2d7cd011db47%7C1%7C0%7C637256213561542812&amp;sdata=3Dd28c2VOQ= %2FCn53uFUGpddqFtL3lmX9Kir7mvKYm7%2BYEw%3D&amp;reserved=3D0

The ReportOutput() function in UnitTestResultReportLib copies characters from a function input buffer to an intermediate local buffer in fixed
size chunks of the maximum size of the intermediate buffer. The
implementation currently calls AsciiStrCpyS() which will ASSERT on an
error.

This commit changes the call to AsciiStrnCpyS() to avoid the
ASSERT which is not expected in the usage of the string copy in this
implementation.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
 UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibConOut.c   | 2 +-
 UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibDebugLib.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestR= esultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportL= ib/UnitTestResultReportLibConOut.c
index 139360ee1657..cfb0c5972bd1 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibConOut.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/Unit= TestResultReportLibConOut.c
@@ -42,7 +42,7 @@ ReportOutput (
 
   Length =3D AsciiStrLen (Output);
   for (Index =3D 0; Index < Length; Index +=3D (sizeof (A= sciiString) - 1)) {
-    AsciiStrCpyS (AsciiString, sizeof (AsciiString), &O= utput[Index]);
+    AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &= amp;Output[Index], sizeof (AsciiString) - 1);
     ReportPrint ("%a", AsciiString);
   }
 }
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestR= esultReportLibDebugLib.c b/UnitTestFrameworkPkg/Library/UnitTestResultRepor= tLib/UnitTestResultReportLibDebugLib.c
index 743aad2958a7..1402d0ef83e2 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultRe= portLibDebugLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/Unit= TestResultReportLibDebugLib.c
@@ -41,7 +41,7 @@ ReportOutput (
 
   Length =3D AsciiStrLen (Output);
   for (Index =3D 0; Index < Length; Index +=3D (sizeof (A= sciiString) - 1)) {
-    AsciiStrCpyS (AsciiString, sizeof (AsciiString), &O= utput[Index]);
+    AsciiStrnCpyS (AsciiString, sizeof (AsciiString), &= amp;Output[Index], sizeof (AsciiString) - 1);
     DEBUG ((DEBUG_INFO, AsciiString));
   }
 }
--
2.16.3.windows.1

--_000_CY4PR21MB0743F0BC6EB5249DC06E953BEFB70CY4PR21MB0743namp_--