summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
authorMike Beaton <mjsbeaton@gmail.com>2023-09-07 11:34:42 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-09-11 01:17:33 +0000
commit0bcc503595fdd8036701dab54eabe4f40ecbb768 (patch)
tree9e4c731196cfb010aa28a29616fe9b85301c7743 /MdeModulePkg/Universal
parentb240eab03530f063ef5438497d70a731b19a201e (diff)
downloadedk2-0bcc503595fdd8036701dab54eabe4f40ecbb768.tar.gz
edk2-0bcc503595fdd8036701dab54eabe4f40ecbb768.tar.bz2
edk2-0bcc503595fdd8036701dab54eabe4f40ecbb768.zip
MdeModulePkg/HiiDatabase: Fix incorrect AllocateCopyPool size
The immediately preceding call, GetBestLanguage, plus the implementation of HiiGetString, which is called immediately afterwards, make it clear that BestLanguage is a null-terminated ASCII string, and not just a five byte, non-null terminated buffer. Therefore AsciiStrLen is one byte too short, meaning that whether the space allocated is really sufficient and whether the resultant string is really null-terminated becomes implementation-dependent. Rather than switching to AsciiStrSize, we use an explicitly compile-time string length calculation (both compile-time and run-time approaches are currently used elsewhere in the codebase for copying static strings). Signed-off-by: Mike Beaton <mjsbeaton@gmail.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
index 96e05d4cf9..6e791783a6 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigKeywordHandler.c
@@ -1987,7 +1987,7 @@ GetNameFromId (
NULL
);
if (BestLanguage == NULL) {
- BestLanguage = AllocateCopyPool (AsciiStrLen ("en-US"), "en-US");
+ BestLanguage = AllocateCopyPool (sizeof ("en-US"), "en-US");
ASSERT (BestLanguage != NULL);
}