]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
ArmPkg/SemihostFs: eliminate calls to deprecated string functions
[mirror_edk2.git] / ArmPkg / Filesystem / SemihostFs / Arm / SemihostFs.c
index 6efdad9ebcce4f5d2e09853170e30d6c8ba993a7..92aa5f8b0e4e83bd3968ec53570aab545a9fa0a3 100644 (file)
@@ -207,11 +207,12 @@ FileOpen (
     return EFI_WRITE_PROTECTED;\r
   }\r
 \r
-  AsciiFileName = AllocatePool (StrLen (FileName) + 1);\r
+  Length = StrLen (FileName) + 1;\r
+  AsciiFileName = AllocatePool (Length);\r
   if (AsciiFileName == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  UnicodeStrToAsciiStr (FileName, AsciiFileName);\r
+  UnicodeStrToAsciiStrS (FileName, AsciiFileName, Length);\r
 \r
   // Opening '/', '\', '.', or the NULL pathname is trying to open the root directory\r
   if ((AsciiStrCmp (AsciiFileName, "\\") == 0) ||\r
@@ -463,7 +464,7 @@ FileDelete (
     NameSize = AsciiStrLen (Fcb->FileName);\r
     FileName = AllocatePool (NameSize + 1);\r
 \r
-    AsciiStrCpy (FileName, Fcb->FileName);\r
+    AsciiStrCpyS (FileName, NameSize + 1, Fcb->FileName);\r
 \r
     // Close the file if it's open.  Disregard return status,\r
     // since it might give an error if the file isn't open.\r
@@ -828,8 +829,10 @@ GetFilesystemInfo (
   EFI_FILE_SYSTEM_INFO  *Info;\r
   EFI_STATUS            Status;\r
   UINTN                 ResultSize;\r
+  UINTN                 StringSize;\r
 \r
-  ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StrSize (mSemihostFsLabel);\r
+  StringSize = StrSize (mSemihostFsLabel);\r
+  ResultSize = SIZE_OF_EFI_FILE_SYSTEM_INFO + StringSize;\r
 \r
   if (*BufferSize >= ResultSize) {\r
     ZeroMem (Buffer, ResultSize);\r
@@ -843,7 +846,7 @@ GetFilesystemInfo (
     Info->FreeSpace  = 0;\r
     Info->BlockSize  = 0;\r
 \r
-    StrCpy (Info->VolumeLabel, mSemihostFsLabel);\r
+    CopyMem (Info->VolumeLabel, mSemihostFsLabel, StringSize);\r
   } else {\r
     Status = EFI_BUFFER_TOO_SMALL;\r
   }\r
@@ -903,7 +906,7 @@ FileGetInfo (
     ResultSize = StrSize (mSemihostFsLabel);\r
 \r
     if (*BufferSize >= ResultSize) {\r
-      StrCpy (Buffer, mSemihostFsLabel);\r
+      CopyMem (Buffer, mSemihostFsLabel, ResultSize);\r
       Status = EFI_SUCCESS;\r
     } else {\r
       Status = EFI_BUFFER_TOO_SMALL;\r
@@ -963,11 +966,12 @@ SetFileInfo (
     return EFI_ACCESS_DENIED;\r
   }\r
 \r
-  AsciiFileName = AllocatePool (StrLen (Info->FileName) + 1);\r
+  Length = StrLen (Info->FileName) + 1;\r
+  AsciiFileName = AllocatePool (Length);\r
   if (AsciiFileName == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
-  UnicodeStrToAsciiStr (Info->FileName, AsciiFileName);\r
+  UnicodeStrToAsciiStrS (Info->FileName, AsciiFileName, Length);\r
 \r
   FileSizeIsDifferent = (Info->FileSize != Fcb->Info.FileSize);\r
   FileNameIsDifferent = (AsciiStrCmp (AsciiFileName, Fcb->FileName) != 0);\r