From 3ee2ceb6fa4ee13484758bc3cd77195262faad07 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Wed, 2 Oct 2024 11:57:42 +0200 Subject: [PATCH] FatPkg/EnhancedFatDxe: Add comments around StrSize() checks StrSize() cannot return 0. As done in other packages, StrSize() checks the length of the string doesn't exceed PcdMaximumUnicodeStringLength. Add comments to make it more obvious. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4859 Reported-by: Tormod Volden Signed-off-by: Pierre Gondois --- FatPkg/EnhancedFatDxe/UnicodeCollation.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/FatPkg/EnhancedFatDxe/UnicodeCollation.c b/FatPkg/EnhancedFatDxe/UnicodeCollation.c index 813f153617ec..6506584ba14c 100644 --- a/FatPkg/EnhancedFatDxe/UnicodeCollation.c +++ b/FatPkg/EnhancedFatDxe/UnicodeCollation.c @@ -166,6 +166,10 @@ FatStriCmp ( IN CHAR16 *S2 ) { + // + // ASSERT s1 and s2 are shorter than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // ASSERT (StrSize (S1) != 0); ASSERT (StrSize (S2) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -189,6 +193,10 @@ FatStrUpr ( IN OUT CHAR16 *String ) { + // + // ASSERT String is shorter than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -207,6 +215,10 @@ FatStrLwr ( IN OUT CHAR16 *String ) { + // + // ASSERT String is shorter than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -231,6 +243,10 @@ FatFatToStr ( ) { ASSERT (Fat != NULL); + // + // ASSERT String is shorter than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // ASSERT (String != NULL); ASSERT (((UINTN)String & 0x01) == 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -257,6 +273,10 @@ FatStrToFat ( ) { ASSERT (Fat != NULL); + // + // ASSERT String is shorter than PcdMaximumUnicodeStringLength. + // Length tests are performed inside StrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL);