[edk2-devel] [PATCH] MdeModulePkg/UefiBootManagerLib: Limit the boot description to 72 chars
Gao, Zhichao
zhichao.gao at intel.com
Tue Sep 7 06:12:52 UTC 2021
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3590
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 <jian.j.wang at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Ray Ni <ray.ni at intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao at intel.com>
---
.../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
Library functions which relate with boot option description.
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -14,6 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define PRODUCT_IDENTIFICATION_OFFSET 11
#define PRODUCT_IDENTIFICATION_LENGTH 16
+#define MAX_BOOT_DESCRIPTION_LEGNTH 72
+
CONST UINT16 mBmUsbLangId = 0x0409; // English
CHAR16 mBmUefiPrefix[] = L"UEFI ";
@@ -773,6 +775,7 @@ BmGetBootDescription (
CHAR16 *DefaultDescription;
CHAR16 *Temp;
UINTN Index;
+ UINTN DescriptionLen;
//
// Firstly get the default boot description
@@ -785,10 +788,23 @@ BmGetBootDescription (
// Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix
// ONLY for core provided boot description handler.
//
- Temp = AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix));
+ if (StrLen (DefaultDescription) + StrLen (mBmUefiPrefix) > MAX_BOOT_DESCRIPTION_LEGNTH) {
+ //
+ // Limit the MAX length of boot description to 72 charactors.
+ // Replace the last 3 charactors to L"...".
+ //
+ DescriptionLen = MAX_BOOT_DESCRIPTION_LEGNTH + 1;
+ DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 3] = L'.';
+ DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 2] = L'.';
+ DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5 - 1] = L'.';
+ DefaultDescription[MAX_BOOT_DESCRIPTION_LEGNTH - 5] = L'\0';
+ } else {
+ DescriptionLen = (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16);
+ }
+ Temp = AllocatePool (DescriptionLen * sizeof (CHAR16));
ASSERT (Temp != NULL);
- StrCpyS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), mBmUefiPrefix);
- StrCatS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), DefaultDescription);
+ StrCpyS (Temp, DescriptionLen, mBmUefiPrefix);
+ StrCatS (Temp, DescriptionLen, DefaultDescription);
FreePool (DefaultDescription);
DefaultDescription = Temp;
break;
--
2.16.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80287): https://edk2.groups.io/g/devel/message/80287
Mute This Topic: https://groups.io/mt/85429661/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list