]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add assertion condition to satisfy the requirement in MdePkg library spec 0.61p
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 7 Apr 2009 09:14:33 +0000 (09:14 +0000)
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 7 Apr 2009 09:14:33 +0000 (09:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8033 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/String.c

index 9a083444b31f1932e3d1465fff0fb25ef08db7a5..bdd31766b94c7bc3e09e748791225400ab6b5862 100644 (file)
@@ -40,7 +40,7 @@
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
@@ -96,8 +96,8 @@ StrCpy (
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
-  Null-terminator, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
+  and Length is greater than PcdMaximumUnicodeStringLength, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -132,6 +132,10 @@ StrnCpy (
   ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r
   ASSERT ((UINTN)(Source - Destination) >= Length);\r
 \r
+  if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+    ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  }\r
+\r
   ReturnValue = Destination;\r
 \r
   while ((*Source != L'\0') && (Length > 0)) {\r
@@ -152,7 +156,7 @@ StrnCpy (
   If String is NULL, then ASSERT().\r
   If String is not aligned on a 16-bit boundary, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated Unicode string.\r
@@ -193,7 +197,7 @@ StrLen (
   If String is NULL, then ASSERT().\r
   If String is not aligned on a 16-bit boundary, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated Unicode string.\r
@@ -225,10 +229,10 @@ StrSize (
   If SecondString is NULL, then ASSERT().\r
   If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
@@ -274,11 +278,12 @@ StrCmp (
   If Length > 0 and SecondString is NULL, then ASSERT().\r
   If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
-  Null-terminator, then ASSERT().\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, and Length is greater than PcdMaximumUnicodeStringLength,\r
+  then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated Unicode string.\r
   @param  SecondString  Pointer to a Null-terminated Unicode string.\r
@@ -307,6 +312,10 @@ StrnCmp (
   ASSERT (StrSize (FirstString) != 0);\r
   ASSERT (StrSize (SecondString) != 0);\r
 \r
+  if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r
+    ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  }\r
+\r
   while ((*FirstString != L'\0') &&\r
          (*FirstString == *SecondString) &&\r
          (Length > 1)) {\r
@@ -334,14 +343,14 @@ StrnCmp (
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
   and Source results in a Unicode string with more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
@@ -386,15 +395,16 @@ StrCat (
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
-  than PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
   If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
   and Source results in a Unicode string with more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the\r
-  Null-terminator, then ASSERT().\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
+  Null-terminator, and Length is greater than PcdMaximumUnicodeStringLength,\r
+  then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated Unicode string.\r
   @param  Source      Pointer to a Null-terminated Unicode string.\r
@@ -439,7 +449,7 @@ StrnCat (
 \r
   If PcdMaximumUnicodeStringLength is not zero, and SearchString\r
   or String contains more than PcdMaximumUnicodeStringLength Unicode\r
-  characters not including the Null-terminator, then ASSERT().\r
+  characters, not including the Null-terminator, then ASSERT().\r
 \r
   @param  String          Pointer to a Null-terminated Unicode string.\r
   @param  SearchString    Pointer to a Null-terminated Unicode string to search for.\r
@@ -621,7 +631,7 @@ InternalIsHexaDecimalDigitCharacter (
   to the range defined by UINTN, then ASSERT().\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains\r
-  more than PcdMaximumUnicodeStringLength Unicode characters not including\r
+  more than PcdMaximumUnicodeStringLength Unicode characters, not including\r
   the Null-terminator, then ASSERT().\r
 \r
   @param  String      Pointer to a Null-terminated Unicode string.\r
@@ -703,7 +713,7 @@ StrDecimalToUintn (
   to the range defined by UINT64, then ASSERT().\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains\r
-  more than PcdMaximumUnicodeStringLength Unicode characters not including\r
+  more than PcdMaximumUnicodeStringLength Unicode characters, not including\r
   the Null-terminator, then ASSERT().\r
 \r
   @param  String          Pointer to a Null-terminated Unicode string.\r
@@ -785,7 +795,7 @@ StrDecimalToUint64 (
   UINTN, then ASSERT().\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
   then ASSERT().\r
 \r
   @param  String          Pointer to a Null-terminated Unicode string.\r
@@ -878,7 +888,7 @@ StrHexToUintn (
   UINT64, then ASSERT().\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
+  PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
   then ASSERT().\r
 \r
   @param  String          Pointer to a Null-terminated Unicode string.\r
@@ -1010,11 +1020,11 @@ InternalAsciiIsHexaDecimalDigitCharacter (
   If Source and Destination overlap, then ASSERT().\r
 \r
   If PcdMaximumUnicodeStringLength is not zero, and Source contains\r
-  more than PcdMaximumUnicodeStringLength Unicode characters not including\r
+  more than PcdMaximumUnicodeStringLength Unicode characters, not including\r
   the Null-terminator, then ASSERT().\r
 \r
   If PcdMaximumAsciiStringLength is not zero, and Source contains more\r
-  than PcdMaximumAsciiStringLength Unicode characters not including the\r
+  than PcdMaximumAsciiStringLength Unicode characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  Source        Pointer to a Null-terminated Unicode string.\r
@@ -1081,7 +1091,7 @@ UnicodeStrToAsciiStr (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
@@ -1133,8 +1143,8 @@ AsciiStrCpy (
   If Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
-  then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
+  and Length is greater than PcdMaximumAsciiStringLength, then ASSERT().\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r
@@ -1168,6 +1178,10 @@ AsciiStrnCpy (
   ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r
   ASSERT ((UINTN)(Source - Destination) >= Length);\r
 \r
+  if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+    ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
   ReturnValue = Destination;\r
 \r
   while (*Source != 0 && Length > 0) {\r
@@ -1188,7 +1202,7 @@ AsciiStrnCpy (
   If Length > 0 and Destination is NULL, then ASSERT().\r
   If Length > 0 and Source is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and String contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated ASCII string.\r
@@ -1227,7 +1241,7 @@ AsciiStrLen (
 \r
   If String is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and String contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
 \r
   @param  String  Pointer to a Null-terminated ASCII string.\r
@@ -1257,10 +1271,10 @@ AsciiStrSize (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  than PcdMaximumAsciiStringLength ASCII characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
@@ -1354,10 +1368,10 @@ InternalAsciiHexCharToUintn (
   If FirstString is NULL, then ASSERT().\r
   If SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
-  than PcdMaximumAsciiStringLength ASCII characters not including the\r
+  than PcdMaximumAsciiStringLength ASCII characters, not including the\r
   Null-terminator, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
@@ -1411,11 +1425,11 @@ AsciiStriCmp (
   If Length > 0 and FirstString is NULL, then ASSERT().\r
   If Length > 0 and SecondString is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and SecondString contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
-  then ASSERT().\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
+  and Length is greater than PcdMaximumAsciiStringLength, then ASSERT().\r
 \r
   @param  FirstString   Pointer to a Null-terminated ASCII string.\r
   @param  SecondString  Pointer to a Null-terminated ASCII string.\r
@@ -1443,6 +1457,10 @@ AsciiStrnCmp (
   ASSERT (AsciiStrSize (FirstString));\r
   ASSERT (AsciiStrSize (SecondString));\r
 \r
+  if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r
+    ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength));\r
+  }\r
+\r
   while ((*FirstString != '\0') &&\r
          (*FirstString == *SecondString) &&\r
          (Length > 1)) {\r
@@ -1465,10 +1483,10 @@ AsciiStrnCmp (
   If Destination is NULL, then ASSERT().\r
   If Source is NULL, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
   Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
@@ -1514,14 +1532,15 @@ AsciiStrCat (
   If Length > 0 and Source is NULL, then ASSERT().\r
   If Source and Destination overlap, then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
-  PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
+  PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
   then ASSERT().\r
   If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
   Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
-  ASCII characters not including the Null-terminator, then ASSERT().\r
+  ASCII characters, not including the Null-terminator, and Length is greater than \r
+  PcdMaximumAsciiStringLength, then ASSERT()..\r
 \r
   @param  Destination Pointer to a Null-terminated ASCII string.\r
   @param  Source      Pointer to a Null-terminated ASCII string.\r