]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/DirectoryManage.c
PcAtChipsetPkg/PcRtc: Handle NULL table entry in RSDT/XSDT
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / DirectoryManage.c
index f9a764d3aa52dd3b4154bb18dcc73e15fda34596..3328ae31fed9432c282d935c73fa217d21b7d1ca 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\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
 http://opensource.org/licenses/bsd-license.php\r
@@ -67,7 +67,7 @@ Returns:
   }\r
 \r
   BufferSize = sizeof (FAT_DIRECTORY_ENTRY);\r
-  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry);\r
+  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry, NULL);\r
 }\r
 \r
 EFI_STATUS\r
@@ -116,7 +116,15 @@ Returns:
     // Write LFN directory entry\r
     //\r
     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);\r
-    StrCpy (LfnBuffer, DirEnt->FileString);\r
+    Status = StrCpyS (\r
+               LfnBuffer,\r
+               ARRAY_SIZE (LfnBuffer),\r
+               DirEnt->FileString\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
     LfnBufferPointer    = LfnBuffer;\r
     LfnEntry.Attributes = FAT_ATTRIBUTE_LFN;\r
     LfnEntry.Type       = 0;\r
@@ -349,7 +357,11 @@ Returns:
     // Fail to get the long file name from long file name entry,\r
     // get the file name from short name\r
     //\r
-    FatGetFileNameViaCaseFlag (DirEnt, LfnBuffer);\r
+    FatGetFileNameViaCaseFlag (\r
+      DirEnt,\r
+      LfnBuffer,\r
+      ARRAY_SIZE (LfnBuffer)\r
+      );\r
   }\r
 \r
   DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer);\r
@@ -1185,6 +1197,7 @@ Returns:
   FAT_ODIR    *ODir;\r
   EFI_STATUS  Status;\r
 \r
+  ASSERT (OFile != NULL);\r
   ODir = OFile->ODir;\r
   ASSERT (ODir != NULL);\r
   DirEnt = AllocateZeroPool (sizeof (FAT_DIRENT));\r
@@ -1376,8 +1389,8 @@ Returns:
   FAT_VOLUME  *Volume;\r
 \r
   OFile   = DirEnt->OFile;\r
-  Volume  = OFile->Volume;\r
   ASSERT (OFile != NULL);\r
+  Volume  = OFile->Volume;\r
 \r
   if (OFile->ODir != NULL) {\r
     FatDiscardODir (OFile);\r