From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web08.32191.1630995179288567971 for ; Mon, 06 Sep 2021 23:12:59 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: zhichao.gao@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10099"; a="207334236" X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="207334236" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2021 23:12:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="502782949" Received: from gaozhic-desk.ccr.corp.intel.com ([10.239.137.133]) by fmsmga008.fm.intel.com with ESMTP; 06 Sep 2021 23:12:56 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Ray Ni Subject: [PATCH] MdeModulePkg/UefiBootManagerLib: Limit the boot description to 72 chars Date: Tue, 7 Sep 2021 14:12:52 +0800 Message-Id: <20210907061252.2069-1-zhichao.gao@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3590 The minimum mode is 80*25 which means echo line can have 80 charactors and max 25 line on the screen. And the BootManagerMeu see each boot option as one line. The BootManagerMenuApp would have 2 charactors for draw box and 6 charactors for space. So it is better to limit the boot description within 72 charactors. Cc: Jian J Wang Cc: Liming Gao Cc: Ray Ni Signed-off-by: Zhichao Gao --- .../Library/UefiBootManagerLib/BmBootDescription.c | 24 ++++++++++++++++++= ---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/= MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index aa891feb17..7260b2a203 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c @@ -1,7 +1,7 @@ /** @file=0D Library functions which relate with boot option description.=0D =0D -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.
=0D (C) Copyright 2015 Hewlett Packard Enterprise Development LP
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -14,6 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #define PRODUCT_IDENTIFICATION_OFFSET 11=0D #define PRODUCT_IDENTIFICATION_LENGTH 16=0D =0D +#define MAX_BOOT_DESCRIPTION_LEGNTH 72=0D +=0D CONST UINT16 mBmUsbLangId =3D 0x0409; // English=0D CHAR16 mBmUefiPrefix[] =3D L"UEFI ";=0D =0D @@ -773,6 +775,7 @@ BmGetBootDescription ( CHAR16 *DefaultDescription;=0D CHAR16 *Temp;=0D UINTN Index;=0D + UINTN DescriptionLen;=0D =0D //=0D // Firstly get the default boot description=0D @@ -785,10 +788,23 @@ BmGetBootDescription ( // Avoid description confusion between UEFI & Legacy boot option by = adding "UEFI " prefix=0D // ONLY for core provided boot description handler.=0D //=0D - Temp =3D AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUef= iPrefix));=0D + if (StrLen (DefaultDescription) + StrLen (mBmUefiPrefix) > MAX_BOOT_= DESCRIPTION_LEGNTH) {=0D + //=0D + // Limit the MAX length of boot description to 72 charactors.=0D + // Replace the last 3 charactors to L"...".=0D + //=0D + DescriptionLen =3D MAX_BOOT_DESCRIPTION_LEGNTH + 1;=0D + DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 3] =3D L'.';= =0D + DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 2] =3D L'.';= =0D + DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 1] =3D L'.';= =0D + DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5] =3D L'\0';=0D + } else {=0D + DescriptionLen =3D (StrSize (DefaultDescription) + sizeof (mBmUefi= Prefix)) / sizeof (CHAR16);=0D + }=0D + Temp =3D AllocatePool (DescriptionLen * sizeof (CHAR16));=0D ASSERT (Temp !=3D NULL);=0D - StrCpyS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix= )) / sizeof (CHAR16), mBmUefiPrefix);=0D - StrCatS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix= )) / sizeof (CHAR16), DefaultDescription);=0D + StrCpyS (Temp, DescriptionLen, mBmUefiPrefix);=0D + StrCatS (Temp, DescriptionLen, DefaultDescription);=0D FreePool (DefaultDescription);=0D DefaultDescription =3D Temp;=0D break;=0D --=20 2.16.2.windows.1