summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Gondois <pierre.gondois@arm.com>2024-10-02 11:57:42 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-11-27 15:57:08 +0000
commit3ee2ceb6fa4ee13484758bc3cd77195262faad07 (patch)
treebb526fdff2e180428f1c08aa2c2f7c1e622adb0e
parentbf32c2d61f3e13e8e0f33fce431376812c99da81 (diff)
downloadedk2-3ee2ceb6fa4ee13484758bc3cd77195262faad07.tar.gz
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 <debian.tormod@gmail.com> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
-rw-r--r--FatPkg/EnhancedFatDxe/UnicodeCollation.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/FatPkg/EnhancedFatDxe/UnicodeCollation.c b/FatPkg/EnhancedFatDxe/UnicodeCollation.c
index 813f153617..6506584ba1 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);