]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/FileName.c
FatPkg EnhancedFatDxe: Use safe string functions
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / FileName.c
index 09690fb07649e606db329badaf0066dadbcbe11f..551cda53b9a4e5b968d4d5f364a61066b7471828 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
@@ -302,7 +302,6 @@ Returns:
   CHAR16  Buffer[FAT_MAIN_NAME_LEN + 1 + FAT_EXTEND_NAME_LEN + 1];\r
   UINT8   OutCaseFlag;\r
 \r
-  ASSERT (StrSize (Str) <= sizeof (Buffer));\r
   //\r
   // Assume the case of input string is mixed\r
   //\r
@@ -311,7 +310,7 @@ Returns:
   // Lower case a copy of the string, if it matches the\r
   // original then the string is lower case\r
   //\r
-  StrCpy (Buffer, Str);\r
+  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);\r
   FatStrLwr (Buffer);\r
   if (StrCmp (Str, Buffer) == 0) {\r
     OutCaseFlag = InCaseFlag;\r
@@ -320,7 +319,7 @@ Returns:
   // Upper case a copy of the string, if it matches the\r
   // original then the string is upper case\r
   //\r
-  StrCpy (Buffer, Str);\r
+  StrCpyS (Buffer, sizeof (Buffer) / sizeof (Buffer[0]), Str);\r
   FatStrUpr (Buffer);\r
   if (StrCmp (Str, Buffer) == 0) {\r
     OutCaseFlag = 0;\r
@@ -392,8 +391,9 @@ Returns:
 \r
 VOID\r
 FatGetFileNameViaCaseFlag (\r
-  IN  FAT_DIRENT    *DirEnt,\r
-  OUT CHAR16        *FileString\r
+  IN     FAT_DIRENT   *DirEnt,\r
+  IN OUT CHAR16       *FileString,\r
+  IN     UINTN        FileStringMax\r
   )\r
 /*++\r
 \r
@@ -425,7 +425,7 @@ Returns:
   FatNameToStr (File8Dot3Name + FAT_MAIN_NAME_LEN, FAT_EXTEND_NAME_LEN, CaseFlag & FAT_CASE_EXT_LOWER, &TempExt[1]);\r
   if (TempExt[1] != 0) {\r
     TempExt[0] = L'.';\r
-    StrCat (FileString, TempExt);\r
+    StrCatS (FileString, FileStringMax, TempExt);\r
   }\r
 }\r
 \r