From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.3266.1603939983158748376 for ; Wed, 28 Oct 2020 19:53:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=fuN4kBhh; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: zailiang.sun@intel.com) IronPort-SDR: Q+g12OcbgaP4xc1nN9rJ7/hkjCHsj4dI17H+WvWc9wY+LkMegsj8Mbxl+E40E+pRejV4BGzeYs kT56k/Z/deYQ== X-IronPort-AV: E=McAfee;i="6000,8403,9788"; a="232552180" X-IronPort-AV: E=Sophos;i="5.77,428,1596524400"; d="scan'208";a="232552180" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2020 19:53:02 -0700 IronPort-SDR: J56zQCpOkqZDlCS1l5vHYX/0cM9Sy7WksE40fFYmxOFawtc9LU/gjp3o4pL16y7ofNC0e+sK56 QQchJTc2VL/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,428,1596524400"; d="scan'208";a="526568725" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP; 28 Oct 2020 19:53:02 -0700 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 28 Oct 2020 19:53:01 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 28 Oct 2020 19:53:01 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 28 Oct 2020 19:53:01 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 28 Oct 2020 19:53:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z2J7xDI2FYwuyokmew0IDxzs5vt9HcS4Pm63CyiHzLzrxlZOGRpO972k6tS3/JWr7VRgywztBylPedvX5XaCTAty+B/ItOy7Ftcta3pm+MmcyJ6NAx3xeIidmmFKkLljphHnypgg8Xi26YnVPEgzvHF1/mDACQ9NQFVJ5huJmNfqURpvTnmlDEhFyF/BED0chvRa3LQPCRIsjWKmbqHvGkLnytiFVbF8J7cpBZzOoj0+UGc6Cw6Kc4VX5jrVoL1u0W7aFq04TzVs7fdytEK0vlw7GKCFV+DlzUdk9JuYOlpHvM++OSgX4uny3YnIBrLdMz7RNOeK0RoU00dY1syciw== 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=5jegwO1z1lhMvx7BoXejR9KOg6NtIQAQU7fxCk6c7H8=; b=YW7COGA+/TuuoMdFrPiAttVRhDtgTW2Y0V0idsdPbpO8ei0t33vzrOIJ2DFsu+T+aXaQlJ4GKpETEYQ0yp2cpnaG+Me7N8/30SyOU8ddp8+xvGAY7PzH+2PUV3VU1wmyp5jUYUvV0J1o3rqMtvOxKfiUTeYqW7HNpUGShI8Sdhb0yNKQX4PGI0lSdSzuJ03dnmkQBY6WVU8hKkmwKmewY8BRxESdf1A9VL7pAR1S89+Bk0AYa885PU0Qpd6JvOf2LxZKKihMy9e8htsL/VlPCfKCrs8nOB/lI3T+msaLPTfVwGK6tbstFh4osObzq781ir5Bqaa3k8tDmxRcKaDGIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5jegwO1z1lhMvx7BoXejR9KOg6NtIQAQU7fxCk6c7H8=; b=fuN4kBhhL43uQ4bqXCz3R2fXGs9DjDcv4k2iRxN0vfACA9ZJrGtwNhufCw8LRNWN6F/d8hGyrsZi34RpS/k9XQdRgIFhl0oyF/prCIxbpZofxgBVC7lGzKCp+lY93TCV++hwmeFliZonYP/BszgTFNc3TNIiD1dCWpTlIfDYkSs= Received: from SA2PR11MB5081.namprd11.prod.outlook.com (2603:10b6:806:118::16) by SA0PR11MB4749.namprd11.prod.outlook.com (2603:10b6:806:9a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Thu, 29 Oct 2020 02:52:58 +0000 Received: from SA2PR11MB5081.namprd11.prod.outlook.com ([fe80::5d4e:ec99:a8ce:7f25]) by SA2PR11MB5081.namprd11.prod.outlook.com ([fe80::5d4e:ec99:a8ce:7f25%4]) with mapi id 15.20.3477.029; Thu, 29 Oct 2020 02:52:58 +0000 From: "Sun, Zailiang" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: "Qian, Yi" Subject: Re: [edk2-platforms][Patch 1/3] Vlv2TbltDevicePkg: Use safe string and PCD functions Thread-Topic: [edk2-platforms][Patch 1/3] Vlv2TbltDevicePkg: Use safe string and PCD functions Thread-Index: AQHWrY67E7nzAqBEqEqFyVVMq9Ihiqmt4g7g Date: Thu, 29 Oct 2020 02:52:58 +0000 Message-ID: References: <20201029005859.1263-1-michael.d.kinney@intel.com> <20201029005859.1263-2-michael.d.kinney@intel.com> In-Reply-To: <20201029005859.1263-2-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.205] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8d229753-3297-46ae-5b09-08d87bb5be46 x-ms-traffictypediagnostic: SA0PR11MB4749: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:519; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: BZr6mkiWzsRAkaCZeEcyOld4zb62g0P5MZ/oEMt/W2uWHCY4q3/6wlAphxEOP0DCI6C0Czz/CsIS19UiHA7H1UK8IhxfwdRZcCC2IowGwBoJ6W6WxrfabIoTppbC44TtqcBN8G0GluUy/GjWNFdafrY88ODgB9CMNYgWM7HgzePfrUnZK6mnQvhfMHEvXmATlKf950FjblyiHAbf6C22HZo3drFPiArfzIs1u2U+epuQYtF1lqIpYTFD7Ie+n9v1OlFy4+TpnROSNu+Lznkzj9XcB1wFfQZ4Dbgsl15W2VM0bkPU5vSFqMLw9TxK9dy0r+scSBzfL23BsmdCOq+Zdixnmiks97V42Q1K1Q823fLLCOdtUMfrWYsfn0WzhsXx x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA2PR11MB5081.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(39860400002)(346002)(396003)(366004)(376002)(186003)(478600001)(4326008)(110136005)(55016002)(71200400001)(26005)(33656002)(45954011)(19627235002)(107886003)(6506007)(53546011)(66574015)(83380400001)(7696005)(86362001)(5660300002)(52536014)(316002)(66446008)(8936002)(9686003)(30864003)(2906002)(76116006)(66946007)(64756008)(8676002)(66556008)(66476007)(559001)(579004)(44824005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: Fopm5yP4AexnHipJB27MBGf0Y1LCw2p0rC7GbiYjvI6wXIJ5CF9Nu8rex5Kw4iEoyneh9EpLUVZ8XF7s7Icdqmq/QQpIwayjpAf0+tHYKBkQhRH4yR0Iwgmhi68vAcbHmLJNCqak7FALvfVrmM8IQO1oyThPCDF0LKXXdSpOeAWLuNDXb0dvrw7cR/orDnFHuyOdmNovur7qCrX2tQgOqZZtHUMx4u5U8m/QpJtMspyqCZHU4lWEMNyYTJgjLkQt/G8bCR/LwGnmbbrQ2rrHaDfXq6tX0N7Cz9URHUfH9aignMmALyObbz+Qht3aG9x0qZOmcgr24hpYGw80eU6oKKIkY7iIiYrt7WO6dvr5WZ7QpacjG7P3W9pTUzzgga6FT3lQUe5khHWUjqtRpi+s50Yvm0Xm3py6i5AE3JEQu86BjCZTHeTCZaNIzYMgCo1mR/jstwsmLZOqBGqxvbhEaOjzjwDcKtLJioS6IS3N/TV8xDum5KK1UrsM/z8PmhNuLSfHpaW6KBZN8kuIh8oAizm2dKReYLiMmA3oHnXm7s919wOOuy9gUZISb69iL6lCETAOcq9xJ455lG82Xg8jDwvkkFQ1epqgsk1HtgMn841BQ0w2F+iW6ew+nwfT+mm0rjpQF/6uOEW+5ichsuhSVQ== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR11MB5081.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d229753-3297-46ae-5b09-08d87bb5be46 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Oct 2020 02:52:58.2960 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: CbTmHcXwScdK/aMTj7gcrrvxLnlfayaHglZKKf+xmKb/CpnijB9AuX0YNWqzpvwfmJfdHG7cw59q4dLRU55v0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4749 Return-Path: zailiang.sun@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zailiang Sun -----Original Message----- From: Michael D Kinney =20 Sent: Thursday, October 29, 2020 8:59 AM To: devel@edk2.groups.io Cc: Sun, Zailiang ; Qian, Yi Subject: [edk2-platforms][Patch 1/3] Vlv2TbltDevicePkg: Use safe string and= PCD functions Update all modules to use safe string functions from BaseLib and PcdLib to address build failures. Cc: Zailiang Sun Cc: Yi Qian Signed-off-by: Michael D Kinney --- .../FirmwareUpdate/FirmwareUpdate.c | 10 +- .../PlatformInitPei/PlatformEarlyInit.c | 6 +- .../PlatformSetupDxe/PlatformSetupDxe.c | 40 +++--- .../PlatformSetupDxe/SetupInfoRecords.c | 39 +++--- .../MiscBaseBoardManufacturerFunction.c | 30 +++-- .../SmBiosMiscDxe/MiscBiosVendorFunction.c | 20 +-- .../MiscChassisManufacturerFunction.c | 28 +++-- .../SmBiosMiscDxe/MiscMemoryDeviceFunction.c | 30 +++-- ...MiscNumberOfInstallableLanguagesFunction.c | 6 +- .../SmBiosMiscDxe/MiscOemStringFunction.c | 10 +- .../SmBiosMiscDxe/MiscOemType0x90Function.c | 28 +++-- .../SmBiosMiscDxe/MiscOemType0x94Function.c | 115 +++++++++++------- .../SmBiosMiscDxe/MiscOnboardDeviceFunction.c | 10 +- ...cPortInternalConnectorDesignatorFunction.c | 12 +- .../MiscProcessorCacheFunction.c | 4 +- .../MiscProcessorInformationFunction.c | 28 +++-- .../MiscSystemLanguageStringFunction.c | 10 +- .../MiscSystemManufacturerFunction.c | 31 +++-- .../MiscSystemOptionStringFunction.c | 10 +- .../MiscSystemSlotDesignationFunction.c | 10 +- .../VlvPlatformInitDxe/IgdOpRegion.c | 4 +- 21 files changed, 297 insertions(+), 184 deletions(-) diff --git a/Platform/Intel/Vlv2TbltDevicePkg/Application/FirmwareUpdate/Fi= rmwareUpdate.c b/Platform/Intel/Vlv2TbltDevicePkg/Application/FirmwareUpdat= e/FirmwareUpdate.c index a2fc54e20e..d4da8537e2 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareU= pdate.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/Application/FirmwareUpdate/FirmwareU= pdate.c @@ -1,10 +1,12 @@ /** @file =20 -Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 **/ =20 @@ -239,7 +241,7 @@ ParseCommandLine ( PrintToken (STRING_TOKEN (STR_FWUPDATE_PATH_ERROR), HiiHandle, Arg= v[Index]); return EFI_INVALID_PARAMETER; } - StrCpy (mInputData.FileName, Argv[Index]); + StrCpyS (mInputData.FileName, sizeof (mInputData.FileName) / sizeof = (CHAR16), Argv[Index]); mInputData.UpdateFromFile =3D TRUE; } } diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarly= Init.c b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit= .c index 59845a69c4..3d3fba4e4c 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -363,9 +363,9 @@ MeasuredBootInit ( ) { if (SystemConfiguration->MeasuredBootEnable) { - PcdSetBool (PcdMeasuredBootEnable, TRUE); + PcdSetBoolS (PcdMeasuredBootEnable, TRUE); } else { - PcdSetBool (PcdMeasuredBootEnable, FALSE); + PcdSetBoolS (PcdMeasuredBootEnable, FALSE); } =20 return EFI_SUCCESS; diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetu= pDxe.c b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe= .c index f3850b2aff..a8a02e2687 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -236,8 +236,8 @@ SystemConfigCallback ( case EFI_BROWSER_ACTION_CHANGING: { if (KeyValue =3D=3D 0x1235) { - StrCpy (StringBuffer1, L"Will you disable PTT ? "); - StrCpy (StringBuffer2, L"Enter (YES) / Esc (NO)"); + StrCpyS (StringBuffer1, 200, L"Will you disable PTT ? "); + StrCpyS (StringBuffer2, 200, L"Enter (YES) / Esc (NO)"); =20 // // Popup a menu to notice user @@ -253,8 +253,8 @@ SystemConfigCallback ( =20 } } else if (KeyValue =3D=3D 0x1236) { - StrCpy (StringBuffer1, L"Will you revoke trust ? "); - StrCpy (StringBuffer2, L"Enter (YES) / Esc (NO)"); + StrCpyS (StringBuffer1, 200, L"Will you revoke trust ? "); + StrCpyS (StringBuffer2, 200, L"Enter (YES) / Esc (NO)"); =20 // // Popup a menu to notice user @@ -271,9 +271,9 @@ SystemConfigCallback ( } } else if (KeyValue =3D=3D 0x1239) { if (Value->u8 =3D=3D 0x00) { - StrCpy (StringBuffer1, L"WARNING: SOC may be damaged due to high te= mperature"); - StrCpy (StringBuffer2, L"when DPTF is disabled and IGD turbo is ena= bled."); - StrCpy (StringBuffer3, L"Press Enter/ESC to continue..."); + StrCpyS (StringBuffer1, 200, L"WARNING: SOC may be damaged due to h= igh temperature"); + StrCpyS (StringBuffer2, 200, L"when DPTF is disabled and IGD turbo = is enabled."); + StrCpyS (StringBuffer3, 200, L"Press Enter/ESC to continue..."); =20 // // Popup a menu to notice user @@ -286,9 +286,9 @@ SystemConfigCallback ( // // Popup a menu to notice user // - StrCpy (StringBuffer1, L"WARNING: All your data on the eMMC will be = lost"); - StrCpy (StringBuffer2, L"Do you really want to enable secure erase o= n eMMC?"); - StrCpy (StringBuffer3, L" Enter (YES) / Esc (NO) = "); + StrCpyS (StringBuffer1, 200, L"WARNING: All your data on the eMMC wi= ll be lost"); + StrCpyS (StringBuffer2, 200, L"Do you really want to enable secure e= rase on eMMC?"); + StrCpyS (StringBuffer3, 200, L" Enter (YES) / Esc (NO) = "); =20 do { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuff= er1, StringBuffer2, StringBuffer3,NULL); @@ -364,8 +364,8 @@ SystemConfigCallback ( // // Popup a menu to notice user // - StrCpy (StringBuffer1, L"Do you want to Commit Changes and Exit?"); - StrCpy (StringBuffer2, L" Enter (YES) / Esc (NO) "); + StrCpyS (StringBuffer1, 200, L"Do you want to Commit Changes and Exi= t?"); + StrCpyS (StringBuffer2, 200, L" Enter (YES) / Esc (NO) = "); =20 do { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuff= er1, StringBuffer2, NULL); @@ -431,8 +431,8 @@ SystemConfigCallback ( // // Popup a menu to notice user // - StrCpy (StringBuffer1, L"Do you want to Discard Changes and Exit?"); - StrCpy (StringBuffer2, L" Enter (YES) / Esc (NO) "); + StrCpyS (StringBuffer1, 200, L"Do you want to Discard Changes and Ex= it?"); + StrCpyS (StringBuffer2, 200, L" Enter (YES) / Esc (NO) = "); =20 do { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuff= er1, StringBuffer2, NULL); @@ -451,8 +451,8 @@ SystemConfigCallback ( // // Popup a menu to notice user // - StrCpy (StringBuffer1, L"Do you want to load setup defaults and Exit= ?"); - StrCpy (StringBuffer2, L" Enter (YES) / Esc (NO) = "); + StrCpyS (StringBuffer1, 200, L"Do you want to load setup defaults an= d Exit?"); + StrCpyS (StringBuffer2, 200, L" Enter (YES) / Esc (NO) = "); =20 do { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuff= er1, StringBuffer2, NULL); @@ -522,9 +522,9 @@ SystemConfigCallback ( ); } } else if ((KeyValue =3D=3D 0x123A) || (KeyValue =3D=3D 0x123B) || (Ke= yValue =3D=3D 0x123C)) { - StrCpy (StringBuffer1, L"WARNING: Enable or disable USB Controller= s will "); - StrCpy (StringBuffer2, L"make global reset to restart system."); - StrCpy (StringBuffer3, L"Press Enter/ESC to continue..."); + StrCpyS (StringBuffer1, 200, L"WARNING: Enable or disable USB Cont= rollers will "); + StrCpyS (StringBuffer2, 200, L"make global reset to restart system= ."); + StrCpyS (StringBuffer3, 200, L"Press Enter/ESC to continue..."); // // Popup a menu to notice user // diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRec= ords.c b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords= .c index 1770d0de42..5a597d86da 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -138,7 +138,7 @@ GetOptionalStringByIndex ( return EFI_NOT_FOUND; } else { *String =3D AllocatePool (StrSize * sizeof (CHAR16)); - AsciiStrToUnicodeStr (OptionalStrStart, *String); + AsciiStrToUnicodeStrS (OptionalStrStart, *String, StrSize); } =20 return EFI_SUCCESS; @@ -418,9 +418,9 @@ PrepareSetupInformation ( Length =3D StrLen(ReleaseDate) + StrLen(ReleaseTime); =20 BuildDateTime =3D AllocateZeroPool ((Length+2) * sizeof(CHAR16)); - StrCpy (BuildDateTime, ReleaseDate); - StrCat (BuildDateTime, L" "); - StrCat (BuildDateTime, ReleaseTime); + StrCpyS (BuildDateTime, Length + 2, ReleaseDate); + StrCatS (BuildDateTime, Length + 2, L" "); + StrCatS (BuildDateTime, Length + 2, ReleaseTime); =20 TokenToUpdate =3D (STRING_REF)STR_BIOS_VERSION_VALUE; DEBUG ((EFI_D_ERROR, "update STR_BIOS_VERSION_VALUE\n")); @@ -991,7 +991,7 @@ UpdatePlatformInformation ( MrcVersion =3D 0x00000000; MrcVersion &=3D 0xffff; Index =3D EfiValueToString (Buffer, MrcVersion/100, PREFIX_ZERO, 0); - StrCat (Buffer, L"."); + StrCatS (Buffer, sizeof (Buffer) / sizeof (CHAR16), L"."); EfiValueToString (Buffer + Index + 1, (MrcVersion%100)/10, PREFIX_ZERO, = 0); EfiValueToString (Buffer + Index + 2, (MrcVersion%100)%10, PREFIX_ZERO, = 0); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MRC_VERSION_VALUE), Buffer, NUL= L); @@ -1081,15 +1081,16 @@ UpdatePlatformInformation ( VOID GetDeviceSpeedString ( CHAR16 *NewString, + UINTN NewStringSize, IN UINTN DeviceSpeed ) { if (DeviceSpeed =3D=3D 0x01) { - StrCat (NewString, L"1.5Gb/s"); + StrCatS (NewString, NewStringSize, L"1.5Gb/s"); } else if (DeviceSpeed =3D=3D 0x02) { - StrCat (NewString, L"3.0Gb/s"); + StrCatS (NewString, NewStringSize, L"3.0Gb/s"); } else if (DeviceSpeed =3D=3D 0x03) { - StrCat (NewString, L"6.0Gb/s"); + StrCatS (NewString, NewStringSize, L"6.0Gb/s"); } else if (DeviceSpeed =3D=3D 0x0) { =20 } @@ -1206,6 +1207,7 @@ IdeDataFilter (void) UINT32 IdeDevice; EFI_ATA_IDENTIFY_DATA *IdentifyDriveInfo; CHAR16 *NewString; + UINTN NewStringSize; CHAR16 SizeString[20]; STRING_REF NameToUpdate; CHAR8 StringBuffer[0x100]; @@ -1216,6 +1218,7 @@ IdeDataFilter (void) // Assume no line strings is longer than 256 bytes. // NewString =3D AllocateZeroPool (0x100); + NewStringSize =3D 0x100 / sizeof (CHAR16); PciDevicePath =3D NULL; =20 // @@ -1334,15 +1337,15 @@ IdeDataFilter (void) DriveSize =3D (UINT32) DivU64x32(MultU64x32(DivU64x32(DriveSize,= 1000), 512), 1000); } =20 - StrCat (NewString, L"("); + StrCatS (NewString, NewStringSize, L"("); EfiValueToString (SizeString, DriveSize/1000, PREFIX_BLANK, 0); - StrCat (NewString, SizeString); - StrCat (NewString, L"."); + StrCatS (NewString, NewStringSize, SizeString); + StrCatS (NewString, NewStringSize, L"."); EfiValueToString (SizeString, (DriveSize%1000)/100, PREFIX_BLANK, = 0); - StrCat (NewString, SizeString); - StrCat (NewString, L"GB"); + StrCatS (NewString, NewStringSize, SizeString); + StrCatS (NewString, NewStringSize, L"GB"); } else { - StrCat (NewString, L"(ATAPI"); + StrCatS (NewString, NewStringSize, L"(ATAPI"); } =20 // @@ -1352,11 +1355,11 @@ IdeDataFilter (void) DeviceSpeed =3D GetChipsetSataPortSpeed(PortNumber); =20 if (DeviceSpeed) { - StrCat (NewString, L"-"); - GetDeviceSpeedString( NewString, DeviceSpeed); + StrCatS (NewString, NewStringSize, L"-"); + GetDeviceSpeedString( NewString, NewStringSize, DeviceSpeed); } =20 - StrCat (NewString, L")"); + StrCatS (NewString, NewStringSize, L")"); =20 HiiSetString(mHiiHandle, NameToUpdate, NewString, NULL); =20 diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardMa= nufacturerFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscB= aseBoardManufacturerFunction.c index 8eddc5c2a6..5bd26f8028 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufactu= rerFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBaseBoardManufactu= rerFunction.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -40,6 +40,7 @@ extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) { CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; UINTN ManuStrLen; UINTN ProductStrLen; UINTN VerStrLen; @@ -167,8 +168,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen += 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStr= Len + 1 + ChassisStrLen +1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + ManuStrLen + 1 + Pro= ductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 = + ChassisStrLen +1 + 1); + OptionalStrSize =3D ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 += SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) + OptionalStrS= ize); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) + OptionalStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2); @@ -217,12 +219,22 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) // // Since we fill NumberOfContainedObjectHandles =3D 0 for simple, just a= fter this filed to fill string // - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= roductStrLen + 1 + VerStrLen + 1); - UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + Prod= uctStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + Produc= tStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1); + UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (ManuStrLen + 1); + OptionalStrSize -=3D (ManuStrLen + 1); + UnicodeStrToAsciiStrS (Product, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (ProductStrLen + 1); + OptionalStrSize -=3D (ProductStrLen + 1); + UnicodeStrToAsciiStrS (Version, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (VerStrLen + 1); + OptionalStrSize -=3D (VerStrLen + 1); + UnicodeStrToAsciiStrS (SerialNumber, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SerialNumStrLen + 1); + OptionalStrSize -=3D (SerialNumStrLen + 1); + UnicodeStrToAsciiStrS (AssertTag, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (AssertTagStrLen + 1); + OptionalStrSize -=3D (AssertTagStrLen + 1); + UnicodeStrToAsciiStrS (Chassis, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBiosVendorF= unction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBiosVendorFu= nction.c index 0fbd5ac0bd..335752021f 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBiosVendorFunction= .c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscBiosVendorFunction= .c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -148,6 +148,7 @@ Base2ToByteWith64KUnit ( MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) { CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; UINTN VendorStrLen; UINTN VerStrLen; UINTN DateStrLen; @@ -203,7 +204,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) Version =3D SmbiosMiscGetString (TokenToGet); =20 ZeroMem (BIOSVersionTemp, sizeof (BIOSVersionTemp)); - StrCat (BIOSVersionTemp,Version); + StrCatS (BIOSVersionTemp, sizeof (BIOSVersionTemp) / sizeof (CHAR16), Ve= rsion); VerStrLen =3D StrLen(BIOSVersionTemp); if (VerStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; @@ -219,8 +220,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen= + 1 + VerStrLen + 1 + DateStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + VendorStrLen + 1 + V= erStrLen + 1 + DateStrLen + 1 + 1); + OptionalStrSize =3D VendorStrLen + 1 + VerStrLen + 1 + DateStrLen + 1 + = 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE0) + OptionalStrS= ize); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE0) + OptionalStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_BIOS_INFORMATION; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE0); @@ -264,9 +266,13 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) SmbiosRecord->EmbeddedControllerFirmwareMinorRelease =3D ForType0InputDa= ta->BiosEmbeddedFirmwareMinorRelease; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Char16String, OptionalStrStart); - UnicodeStrToAsciiStr(BIOSVersionTemp, OptionalStrStart + VendorStrLen + = 1); - UnicodeStrToAsciiStr(ReleaseDate, OptionalStrStart + VendorStrLen + 1 + = VerStrLen + 1); + UnicodeStrToAsciiStrS(Char16String, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (VendorStrLen + 1); + OptionalStrSize -=3D (VendorStrLen + 1); + UnicodeStrToAsciiStrS(BIOSVersionTemp, OptionalStrStart, OptionalStrSize= ); + OptionalStrStart +=3D (VerStrLen + 1); + OptionalStrSize -=3D (VerStrLen + 1); + UnicodeStrToAsciiStrS(ReleaseDate, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscChassisManu= facturerFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscCha= ssisManufacturerFunction.c index c42ba3d0d1..75016eb9fa 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscChassisManufacture= rFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscChassisManufacture= rFunction.c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 Module Name: @@ -40,6 +42,7 @@ extern EFI_PLATFORM_INFO_HOB *mPlatformInfo; MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) { CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; UINTN ManuStrLen; UINTN VerStrLen; UINTN AssertTagStrLen; @@ -99,8 +102,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen += 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + Ve= rStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); + OptionalStrSize =3D ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + = 1 + AssertTagStrLen + 1 + 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + OptionalStrS= ize); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + OptionalStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE3); @@ -137,10 +141,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOem= Defined, 4); =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + V= erStrLen + 1); - UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerS= trLen + 1 + SerialNumStrLen + 1); + UnicodeStrToAsciiStrS(Manufacturer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (ManuStrLen + 1); + OptionalStrSize -=3D (ManuStrLen + 1); + UnicodeStrToAsciiStrS(Version, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (VerStrLen + 1); + OptionalStrSize -=3D (VerStrLen + 1); + UnicodeStrToAsciiStrS(SerialNumber, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SerialNumStrLen + 1); + OptionalStrSize -=3D (SerialNumStrLen + 1); + UnicodeStrToAsciiStrS(AssertTag, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscMemoryDevic= eFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscMemoryDevi= ceFunction.c index 3e74ec31db..e64e4bd2a0 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscMemoryDeviceFuncti= on.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscMemoryDeviceFuncti= on.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -81,6 +81,7 @@ GetType16Hndl ( MISC_SMBIOS_TABLE_FUNCTION( MiscMemoryDevice ) { CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; UINTN MemDeviceStrLen; UINTN MemBankLocatorStrLen; UINTN MemManufacturerStrLen; @@ -246,8 +247,9 @@ MISC_SMBIOS_TABLE_FUNCTION( MiscMemoryDevice ) // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE17) + MemDevi= ceStrLen + 1 + MemBankLocatorStrLen + 1 + MemManufacturerStrLen + 1 + MemSe= rialNumberStrLen + 1 + MemAssetTagStrLen+1 + MemPartNumberStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE17) + MemDeviceStrLe= n + 1 + MemBankLocatorStrLen + 1 + MemManufacturerStrLen + 1 + MemSerialNum= berStrLen + 1 + MemAssetTagStrLen+1 + MemPartNumberStrLen + 1 + 1); + OptionalStrSize =3D MemDeviceStrLen + 1 + MemBankLocatorStrLen + 1 += MemManufacturerStrLen + 1 + MemSerialNumberStrLen + 1 + MemAssetTagStrLen+= 1 + MemPartNumberStrLen + 1 + 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE17) + Optiona= lStrSize); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE17) + OptionalStrSiz= e); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_MEMORY_DEVICE; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE17); @@ -287,12 +289,22 @@ MISC_SMBIOS_TABLE_FUNCTION( MiscMemoryDevice ) SmbiosRecord->MemoryType =3D MemoryType; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(MemDevice, OptionalStrStart); - UnicodeStrToAsciiStr(MemBankLocator, OptionalStrStart + MemDeviceStr= Len + 1); - UnicodeStrToAsciiStr(MemManufacturer, OptionalStrStart + MemDeviceSt= rLen + 1 + MemBankLocatorStrLen + 1); - UnicodeStrToAsciiStr(MemSerialNumber, OptionalStrStart + MemDeviceSt= rLen + 1 + MemBankLocatorStrLen + 1 + MemManufacturerStrLen + 1); - UnicodeStrToAsciiStr(MemAssetTag, OptionalStrStart + MemDeviceStrLen= + 1 + MemBankLocatorStrLen + 1 + MemManufacturerStrLen + 1 + MemSerialNumb= erStrLen + 1); - UnicodeStrToAsciiStr(MemPartNumber, OptionalStrStart + MemDeviceStrL= en + 1 + MemBankLocatorStrLen + 1 + MemManufacturerStrLen + 1 + MemSerialNu= mberStrLen + 1+ MemAssetTagStrLen+1 ); + UnicodeStrToAsciiStrS (MemDevice, OptionalStrStart, OptionalStrSize)= ; + OptionalStrStart +=3D (MemDeviceStrLen + 1); + OptionalStrSize -=3D (MemDeviceStrLen + 1); + UnicodeStrToAsciiStrS (MemBankLocator, OptionalStrStart, OptionalStr= Size); + OptionalStrStart +=3D (MemBankLocatorStrLen + 1); + OptionalStrSize -=3D (MemBankLocatorStrLen + 1); + UnicodeStrToAsciiStrS (MemManufacturer, OptionalStrStart, OptionalSt= rSize); + OptionalStrStart +=3D (MemManufacturerStrLen + 1); + OptionalStrSize -=3D (MemManufacturerStrLen + 1); + UnicodeStrToAsciiStrS (MemSerialNumber, OptionalStrStart, OptionalSt= rSize); + OptionalStrStart +=3D (MemSerialNumberStrLen + 1); + OptionalStrSize -=3D (MemSerialNumberStrLen + 1); + UnicodeStrToAsciiStrS (MemAssetTag, OptionalStrStart, OptionalStrSiz= e); + OptionalStrStart +=3D (MemAssetTagStrLen + 1); + OptionalStrSize -=3D (MemAssetTagStrLen + 1); + UnicodeStrToAsciiStrS (MemPartNumber, OptionalStrStart, OptionalStrS= ize); =20 // // Now we have got the full smbios record, call smbios protocol to a= dd this record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscNumberOfIns= tallableLanguagesFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDx= e/MiscNumberOfInstallableLanguagesFunction.c index 4a96a2c465..24bf6250e4 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscNumberOfInstallabl= eLanguagesFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscNumberOfInstallabl= eLanguagesFunction.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
=20 =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -56,7 +56,7 @@ CurrentLanguageMatch ( return; } =20 - CurrentLang =3D GetEfiGlobalVariable (L"PlatformLang"); + GetEfiGlobalVariable2 (L"PlatformLang", &CurrentLang, NULL); DefaultLang =3D (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang= ); BestLanguage =3D GetBestLanguage ( Languages, @@ -234,7 +234,7 @@ MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages= ) SmbiosRecord->Flags =3D (UINT8)ForType13InputData->LanguageFlags.Abbrevi= atedLanguageFormat; SmbiosRecord->CurrentLanguages =3D 1; OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - AsciiStrCpy(OptionalStrStart, CurrentLang); + AsciiStrCpyS(OptionalStrStart, LangStrLen + 1 + 1, CurrentLang); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemStringFu= nction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemStringFunc= tion.c index 8624481149..50d16a196b 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemStringFunction.= c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemStringFunction.= c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 Module Name: =20 @@ -72,7 +74,7 @@ MISC_SMBIOS_TABLE_FUNCTION(OemString) SmbiosRecord->Hdr.Handle =3D 0; SmbiosRecord->StringCount =3D 1; OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(OemStr, OptionalStrStart); + UnicodeStrToAsciiStrS (OemStr, OptionalStrStart, OemStrLen + 1 + 1); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x90= Function.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x90= Function.c index d5a4243624..1aa632ccef 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x90Functio= n.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x90Functio= n.c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved. - = =20 +Copyright (c) 1999 - 2020, Intel Corporation. All rights reserved. + = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 =20 @@ -286,6 +288,7 @@ AddSmbiosT0x90Callback ( CHAR16 *Stepping; STRING_REF TokenToGet; CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; EFI_SMBIOS_PROTOCOL *SmbiosProtocol; =20 DEBUG ((EFI_D_INFO, "Executing SMBIOS T0x90 callback.\n")); @@ -340,8 +343,9 @@ AddSmbiosT0x90Callback ( return EFI_UNSUPPORTED; } =20 - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE90) + SECVerStrLe= n + 1 + uCodeVerStrLen + 1 + GOPStrLen + 1 + SteppingStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE90) + SECVerStrLen + 1 + = uCodeVerStrLen + 1 + GOPStrLen + 1 + SteppingStrLen + 1 + 1); + OptionalStrSize =3D SECVerStrLen + 1 + uCodeVerStrLen + 1 + GOPStrLen + = 1 + SteppingStrLen + 1 + 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE90) + OptionalStr= Size); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE90) + OptionalStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_FIRMWARE_VERSION_INFO; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE90); @@ -372,10 +376,16 @@ AddSmbiosT0x90Callback ( SmbiosRecord->CpuStepping =3D 4; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(SECVer, OptionalStrStart); - UnicodeStrToAsciiStr(uCodeVer, OptionalStrStart + SECVerStrLen + 1); - UnicodeStrToAsciiStr(GOPVer, OptionalStrStart + SECVerStrLen + 1 + uCode= VerStrLen + 1); - UnicodeStrToAsciiStr(Stepping, OptionalStrStart + SECVerStrLen + 1 + uCo= deVerStrLen + 1 + GOPStrLen + 1); + UnicodeStrToAsciiStrS (SECVer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SECVerStrLen + 1); + OptionalStrSize -=3D (SECVerStrLen + 1); + UnicodeStrToAsciiStrS (uCodeVer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (uCodeVerStrLen + 1); + OptionalStrSize -=3D (uCodeVerStrLen + 1); + UnicodeStrToAsciiStrS (GOPVer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (GOPStrLen + 1); + OptionalStrSize -=3D (GOPStrLen + 1); + UnicodeStrToAsciiStrS (Stepping, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94= Function.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94= Function.c index f1bb15ae6e..54915e9053 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Functio= n.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOemType0x94Functio= n.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 1999 - 2019, Intel Corporation. All rights reserved. +Copyright (c) 1999 - 2020, Intel Corporation. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -604,7 +604,7 @@ UpdatePlatformInformation ( MrcVersion =3D MmioRead32 (MmPciAddress (0, 0, 0, 0, 0xF0)); MrcVersion &=3D 0xffff; Index =3D EfiValueToString (Buffer, MrcVersion/100, PREFIX_ZERO, 0); - StrCat (Buffer, L"."); + StrCatS (Buffer, sizeof (Buffer) / sizeof (CHAR16), L"."); EfiValueToString (Buffer + Index + 1, (MrcVersion%100)/10, PREFIX_ZERO, = 0); EfiValueToString (Buffer + Index + 2, (MrcVersion%100)%10, PREFIX_ZERO, = 0); HiiSetString(mHiiHandle,STRING_TOKEN(STR_MISC_MRC_VERSION_VALUE), Buffer= , NULL); @@ -1064,72 +1064,95 @@ AddSmbiosT0x94Callback ( =20 =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(GOPVer, OptionalStrStart); - StrIdx +=3D GOPStrLen + 1; + RecordLen -=3D sizeof (SMBIOS_TABLE_TYPE94); + UnicodeStrToAsciiStrS (GOPVer, OptionalStrStart, RecordLen); + StrIdx +=3D GOPStrLen + 1; + RecordLen -=3D GOPStrLen + 1; =20 - UnicodeStrToAsciiStr(SECVer, OptionalStrStart + StrIdx); - StrIdx +=3D SECVerStrLen + 1; + UnicodeStrToAsciiStrS (SECVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D SECVerStrLen + 1; + RecordLen -=3D SECVerStrLen + 1; =20 - UnicodeStrToAsciiStr(MrcVer, OptionalStrStart + StrIdx); - StrIdx +=3D MRCVersionStrLen + 1; + UnicodeStrToAsciiStrS (MrcVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D MRCVersionStrLen + 1; + RecordLen -=3D MRCVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(uCodeVer, OptionalStrStart + StrIdx); - StrIdx +=3D uCodeVerStrLen + 1; + UnicodeStrToAsciiStrS (uCodeVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D uCodeVerStrLen + 1; + RecordLen -=3D uCodeVerStrLen + 1; =20 - UnicodeStrToAsciiStr(PunitVer, OptionalStrStart + StrIdx); - StrIdx +=3D PUNITVersionStrLen + 1; + UnicodeStrToAsciiStrS (PunitVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D PUNITVersionStrLen + 1; + RecordLen -=3D PUNITVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(PmcVer, OptionalStrStart + StrIdx); - StrIdx +=3D PMCVersionStrLen + 1; + UnicodeStrToAsciiStrS (PmcVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D PMCVersionStrLen + 1; + RecordLen -=3D PMCVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(UlpmcVer, OptionalStrStart + StrIdx); - StrIdx +=3D ULPMCVersionStrLen + 1; + UnicodeStrToAsciiStrS (UlpmcVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D ULPMCVersionStrLen + 1; + RecordLen -=3D ULPMCVersionStrLen + 1; =20 =20 - UnicodeStrToAsciiStr(SocVer, OptionalStrStart + StrIdx); - StrIdx +=3D SOCVersionStrLen +1; + UnicodeStrToAsciiStrS (SocVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D SOCVersionStrLen +1; + RecordLen -=3D SOCVersionStrLen +1; =20 - UnicodeStrToAsciiStr(BoardVer, OptionalStrStart + StrIdx); - StrIdx +=3D BOARDVersionStrLen + 1; + UnicodeStrToAsciiStrS (BoardVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D BOARDVersionStrLen + 1; + RecordLen -=3D BOARDVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(FabVer, OptionalStrStart + StrIdx); - StrIdx +=3D FABVersionStrLen + 1; + UnicodeStrToAsciiStrS (FabVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D FABVersionStrLen + 1; + RecordLen -=3D FABVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(CpuFlavor, OptionalStrStart + StrIdx); - StrIdx +=3D CPUFLAVORStrLen + 1; + UnicodeStrToAsciiStrS (CpuFlavor, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D CPUFLAVORStrLen + 1; + RecordLen -=3D CPUFLAVORStrLen + 1; =20 - UnicodeStrToAsciiStr(BiosVer, OptionalStrStart + StrIdx); - StrIdx +=3D BIOSVersionStrLen + 1; + UnicodeStrToAsciiStrS (BiosVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D BIOSVersionStrLen + 1; + RecordLen -=3D BIOSVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(PmicVer, OptionalStrStart + StrIdx); - StrIdx +=3D PMICVersionStrLen + 1; + UnicodeStrToAsciiStrS (PmicVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D PMICVersionStrLen + 1; + RecordLen -=3D PMICVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(TouchVer, OptionalStrStart + StrIdx); - StrIdx +=3D TOUCHVersionStrLen + 1; + UnicodeStrToAsciiStrS (TouchVer, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D TOUCHVersionStrLen + 1; + RecordLen -=3D TOUCHVersionStrLen + 1; =20 - UnicodeStrToAsciiStr(SecureBootMode, OptionalStrStart + StrIdx); - StrIdx +=3D SecureBootModeLen + 1; + UnicodeStrToAsciiStrS (SecureBootMode, OptionalStrStart + StrIdx, Record= Len); + StrIdx +=3D SecureBootModeLen + 1; + RecordLen -=3D SecureBootModeLen + 1; =20 - UnicodeStrToAsciiStr(BootMode, OptionalStrStart + StrIdx); - StrIdx +=3D BootModeLen + 1; + UnicodeStrToAsciiStrS (BootMode, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D BootModeLen + 1; + RecordLen -=3D BootModeLen + 1; =20 - UnicodeStrToAsciiStr(SpeedStepMode, OptionalStrStart + StrIdx); - StrIdx +=3D SpeedStepModeLen + 1; + UnicodeStrToAsciiStrS (SpeedStepMode, OptionalStrStart + StrIdx, RecordL= en); + StrIdx +=3D SpeedStepModeLen + 1; + RecordLen -=3D SpeedStepModeLen + 1; =20 - UnicodeStrToAsciiStr(CpuTurbo, OptionalStrStart + StrIdx); - StrIdx +=3D CpuTurboLen + 1; + UnicodeStrToAsciiStrS (CpuTurbo, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D CpuTurboLen + 1; + RecordLen -=3D CpuTurboLen + 1; =20 - UnicodeStrToAsciiStr(MaxCState, OptionalStrStart + StrIdx); - StrIdx +=3D MaxCStateLen + 1; + UnicodeStrToAsciiStrS (MaxCState, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D MaxCStateLen + 1; + RecordLen -=3D MaxCStateLen + 1; =20 - UnicodeStrToAsciiStr(GfxTurbo, OptionalStrStart + StrIdx); - StrIdx +=3D GfxTurboLen + 1; + UnicodeStrToAsciiStrS (GfxTurbo, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D GfxTurboLen + 1; + RecordLen -=3D GfxTurboLen + 1; =20 - UnicodeStrToAsciiStr(IdleReserve, OptionalStrStart + StrIdx); - StrIdx +=3D S0ixLen + 1; + UnicodeStrToAsciiStrS (IdleReserve, OptionalStrStart + StrIdx, RecordLen= ); + StrIdx +=3D S0ixLen + 1; + RecordLen -=3D S0ixLen + 1; =20 - UnicodeStrToAsciiStr(RC6, OptionalStrStart + StrIdx); - StrIdx +=3D RC6Len + 1; + UnicodeStrToAsciiStrS (RC6, OptionalStrStart + StrIdx, RecordLen); + StrIdx +=3D RC6Len + 1; + RecordLen -=3D RC6Len + 1; =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOnboardDevi= ceFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOnboardDe= viceFunction.c index aef25065b8..1a02dbb349 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOnboardDeviceFunct= ion.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscOnboardDeviceFunct= ion.c @@ -1,10 +1,12 @@ /** @file =20 -Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 1999 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 Module Name: @@ -118,7 +120,7 @@ MISC_SMBIOS_TABLE_FUNCTION ( SmbiosRecord->Device[0].DeviceType =3D StatusAndType; SmbiosRecord->Device[0].DescriptionString =3D 1; OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(DeviceDescription, OptionalStrStart); + UnicodeStrToAsciiStrS (DeviceDescription, OptionalStrStart, DescriptionS= trLen + 1 + 1); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPortInterna= lConnectorDesignatorFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMis= cDxe/MiscPortInternalConnectorDesignatorFunction.c index 6bc088cd13..73975809db 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPortInternalConnec= torDesignatorFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPortInternalConnec= torDesignatorFunction.c @@ -1,10 +1,12 @@ /** @file =20 -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2004 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 Module Name: @@ -134,8 +136,8 @@ MISC_SMBIOS_TABLE_FUNCTION ( SmbiosRecord->PortType =3D (UINT8)ForType8InputData->PortType; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(InternalRef, OptionalStrStart); - UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen += 1); + UnicodeStrToAsciiStrS (InternalRef, OptionalStrStart, InternalRefStrLen = + 1 + ExternalRefStrLen + 1 + 1); + UnicodeStrToAsciiStrS (ExternalRef, OptionalStrStart + InternalRefStrLen= + 1, ExternalRefStrLen + 1 + 1); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorCa= cheFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcesso= rCacheFunction.c index c64e87e20b..fadace2205 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorCacheFunc= tion.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorCacheFunc= tion.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -147,7 +147,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscProcessorCache) // SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED; OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(SocketDesignation, OptionalStrStart); + UnicodeStrToAsciiStrS (SocketDesignation, OptionalStrStart, + 7 + 1 + = 1); =20 Smbios->Add( Smbios, diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorIn= formationFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPr= ocessorInformationFunction.c index 8a52d017c1..3360bdc541 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorInformati= onFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscProcessorInformati= onFunction.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -199,6 +199,7 @@ MeasureTscFrequency ( MISC_SMBIOS_TABLE_FUNCTION (MiscProcessorInformation) { CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; EFI_STRING SerialNumber; CHAR16 *Version=3DNULL; CHAR16 *Manufacturer=3DNULL; @@ -306,7 +307,8 @@ MISC_SMBIOS_TABLE_FUNCTION (MiscProcessorInformation) // // Two zeros following the last string. // - SmbiosRecord =3D AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE4) + AssetT= agStrLen + 1 + SocketStrLen + 1+ ManufacturerStrLen +1 + VersionStrLen+ 1+ = SerialNumberStrLen + 1 + PartNumberStrLen+ 1 + 1); + OptionalStrSize =3D AssetTagStrLen + 1 + SocketStrLen + 1+ Manufacture= rStrLen +1 + VersionStrLen+ 1+ SerialNumberStrLen + 1 + PartNumberStrLen+ 1= + 1; + SmbiosRecord =3D AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE4) + Option= alStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE4); @@ -421,12 +423,22 @@ MISC_SMBIOS_TABLE_FUNCTION (MiscProcessorInformation) SmbiosRecord->L3CacheHandle =3D L3CacheHandle; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Socket, OptionalStrStart); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart + SocketStrLen + 1= ); - UnicodeStrToAsciiStr(Version, OptionalStrStart + SocketStrLen + 1 + Ma= nufacturerStrLen+ 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + SocketStrLen + 1= + VersionStrLen + 1 + ManufacturerStrLen + 1); - UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + SerialNumberStrLen += 1 + VersionStrLen + 1 + ManufacturerStrLen + 1 + SocketStrLen + 1); - UnicodeStrToAsciiStr(PartNumber, OptionalStrStart + SerialNumberStrLen= + 1 + VersionStrLen + 1 + ManufacturerStrLen + 1 + SocketStrLen + 1 + Asse= tTagStrLen + 1 ); + UnicodeStrToAsciiStrS (Socket, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SocketStrLen + 1); + OptionalStrSize -=3D (SocketStrLen + 1); + UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, OptionalStrSize= ); + OptionalStrStart +=3D (ManufacturerStrLen + 1); + OptionalStrSize -=3D (ManufacturerStrLen + 1); + UnicodeStrToAsciiStrS (Version, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (VersionStrLen + 1); + OptionalStrSize -=3D (VersionStrLen + 1); + UnicodeStrToAsciiStrS (SerialNumber, OptionalStrStart, OptionalStrSize= ); + OptionalStrStart +=3D (SerialNumberStrLen + 1); + OptionalStrSize -=3D (SerialNumberStrLen + 1); + UnicodeStrToAsciiStrS (AssetTag, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (AssetTagStrLen + 1); + OptionalStrSize -=3D (AssetTagStrLen + 1); + UnicodeStrToAsciiStrS (PartNumber, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full Smbios record, call Smbios protocol to add= this record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemLangu= ageStringFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSy= stemLanguageStringFunction.c index 8abfa4074a..70f44f9290 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemLanguageStri= ngFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemLanguageStri= ngFunction.c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 Module Name: =20 @@ -75,7 +77,7 @@ MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString) SmbiosRecord->Flags =3D 1; SmbiosRecord->CurrentLanguages =3D 1; OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Str, OptionalStrStart); + UnicodeStrToAsciiStrS (Str, OptionalStrStart, StrLeng + 1 + 1); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManuf= acturerFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSyst= emManufacturerFunction.c index b18dbd6ae2..efeebc92b8 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturer= Function.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemManufacturer= Function.c @@ -1,6 +1,6 @@ /*++ =20 -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -47,6 +47,7 @@ AddSmbiosManuCallback ( { =20 CHAR8 *OptionalStrStart; + UINTN OptionalStrSize; UINTN ManuStrLen; UINTN VerStrLen; UINTN PdNameStrLen; @@ -245,8 +246,9 @@ AddSmbiosManuCallback ( // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen += 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrL= en + 1 + FamilyNameStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen + 1 += FamilyNameStrLen + 1 + 1); + OptionalStrSize =3D ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + = SerialNumStrLen + 1 + SkuNumberStrLen + 1 + FamilyNameStrLen + 1 + 1; + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE1) + OptionalStrS= ize); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE1) + OptionalStrSize); =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_SYSTEM_INFORMATION; SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE1); @@ -290,13 +292,22 @@ AddSmbiosManuCallback ( SmbiosRecord->WakeUpType =3D (UINT8)ForType1InputData->SystemWakeupType; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(ProductName, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + PdName= StrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + P= dNameStrLen + 1 + VerStrLen + 1); - - UnicodeStrToAsciiStr(SkuNumber, OptionalStrStart + ManuStrLen + 1 + PdNa= meStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); - UnicodeStrToAsciiStr(FamilyName, OptionalStrStart + ManuStrLen + 1 + PdN= ameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SkuNumberStrLen +1); + UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (ManuStrLen + 1); + OptionalStrSize -=3D (ManuStrLen + 1); + UnicodeStrToAsciiStrS (ProductName, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (PdNameStrLen + 1); + OptionalStrSize -=3D (PdNameStrLen + 1); + UnicodeStrToAsciiStrS (Version, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (VerStrLen + 1); + OptionalStrSize -=3D (VerStrLen + 1); + UnicodeStrToAsciiStrS (SerialNumber, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SerialNumStrLen + 1); + OptionalStrSize -=3D (SerialNumStrLen + 1); + UnicodeStrToAsciiStrS (SkuNumber, OptionalStrStart, OptionalStrSize); + OptionalStrStart +=3D (SkuNumberStrLen + 1); + OptionalStrSize -=3D (SkuNumberStrLen + 1); + UnicodeStrToAsciiStrS (FamilyName, OptionalStrStart, OptionalStrSize); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemOptio= nStringFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSyst= emOptionStringFunction.c index ee27a75e3a..1609bca79b 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemOptionString= Function.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemOptionString= Function.c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 Module Name: @@ -75,7 +77,7 @@ MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString) =20 SmbiosRecord->StringCount =3D 1; OptionalStrStart =3D (CHAR8*) (SmbiosRecord + 1); - UnicodeStrToAsciiStr(OptionString, OptionalStrStart); + UnicodeStrToAsciiStrS (OptionString, OptionalStrStart, OptStrLen + 1 + 1= ); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemSlotD= esignationFunction.c b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscS= ystemSlotDesignationFunction.c index 7270ef826f..aeed9a79a9 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemSlotDesignat= ionFunction.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSystemSlotDesignat= ionFunction.c @@ -1,10 +1,12 @@ /*++ =20 -Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- = =20 +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+ = =20 + SPDX-License-Identifier: BSD-2-Clause-Patent =20 - = =20 + = =20 + =20 =20 Module Name: @@ -111,7 +113,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation) // CopyMem ((UINT8 *) &SmbiosRecord->SlotCharacteristics1,(UINT8 *) &ForTyp= e9InputData->SlotCharacteristics,2); OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart); + UnicodeStrToAsciiStrS (SlotDesignation, OptionalStrStart, SlotDesignatio= nStrLen + 1 + 1); // // Now we have got the full smbios record, call smbios protocol to add t= his record. // diff --git a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegio= n.c b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c index 3815c8fa9c..970a3271c5 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c +++ b/Platform/Intel/Vlv2TbltDevicePkg/VlvPlatformInitDxe/IgdOpRegion.c @@ -1,7 +1,7 @@ =20 /*++ =20 -Copyright (c) 2011 - 2019, Intel Corporation. All rights reserved +Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -499,7 +499,7 @@ SetGOPVersionCallback ( ZeroMem (GopVersion, sizeof (GopVersion)); Status =3D GetGOPDriverVersion(GopVersion); if(!EFI_ERROR(Status)) { - StrCpy((CHAR16*)&(mIgdOpRegion.OpRegion->Header.GOPV[0]), GopVersion); + StrCpyS ((CHAR16*)&(mIgdOpRegion.OpRegion->Header.GOPV[0]), 16, GopVer= sion); return Status; } return EFI_UNSUPPORTED; --=20 2.28.0.windows.1