Skip to content

Commit

Permalink
FatPkg/EnhancedFatDxe: Add comments around StrSize() checks
Browse files Browse the repository at this point in the history
StrSize() cannot return 0. As done in other packages, StrSize()
checks the length of the string doesn't exceed
PcdMaximumAsciiStringLength. Add comments to make it more obvious.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4859
Reported-by: Tormod Volden <[email protected]>
Signed-off-by: Pierre Gondois <[email protected]>
  • Loading branch information
pierregondois committed Nov 6, 2024
1 parent c7e15d0 commit 0f3dc21
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions FatPkg/EnhancedFatDxe/UnicodeCollation.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ FatStriCmp (
IN CHAR16 *S2
)
{
//
// ASSERT s1 and s2 are shorter than PcdMaximumAsciiStringLength.
// Length tests are performed inside AsciiStrLen().
//
ASSERT (StrSize (S1) != 0);
ASSERT (StrSize (S2) != 0);
ASSERT (mUnicodeCollationInterface != NULL);
Expand All @@ -189,6 +193,10 @@ FatStrUpr (
IN OUT CHAR16 *String
)
{
//
// ASSERT String is shorter than PcdMaximumAsciiStringLength.
// Length tests are performed inside AsciiStrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);

Expand All @@ -207,6 +215,10 @@ FatStrLwr (
IN OUT CHAR16 *String
)
{
//
// ASSERT String is shorter than PcdMaximumAsciiStringLength.
// Length tests are performed inside AsciiStrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);

Expand All @@ -231,6 +243,10 @@ FatFatToStr (
)
{
ASSERT (Fat != NULL);
//
// ASSERT String is shorter than PcdMaximumAsciiStringLength.
// Length tests are performed inside AsciiStrLen().
//
ASSERT (String != NULL);
ASSERT (((UINTN)String & 0x01) == 0);
ASSERT (mUnicodeCollationInterface != NULL);
Expand All @@ -257,6 +273,10 @@ FatStrToFat (
)
{
ASSERT (Fat != NULL);
//
// ASSERT String is shorter than PcdMaximumAsciiStringLength.
// Length tests are performed inside AsciiStrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);

Expand Down

0 comments on commit 0f3dc21

Please sign in to comment.