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
PcdMaximumUnicodeStringLength. 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 authored and mergify[bot] committed Nov 27, 2024
1 parent bf32c2d commit 3ee2ceb
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 PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
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 PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);

Expand All @@ -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);

Expand All @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit 3ee2ceb

Please sign in to comment.