X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=FatPkg%2FEnhancedFatDxe%2FDirectoryManage.c;h=91e7599e272258e465f485c35416af0f33c16208;hb=265fff39483bc2e1550bbb9546b9c330e6118e25;hp=9fdb7affe4547b4a9c4beeec805d17f33762e5d6;hpb=c3b8ec4310a6a5a51854e19285f4057a01ca08fc;p=mirror_edk2.git diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDxe/DirectoryManage.c index 9fdb7affe4..91e7599e27 100644 --- a/FatPkg/EnhancedFatDxe/DirectoryManage.c +++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c @@ -1,7 +1,7 @@ /*++ -Copyright (c) 2005 - 2007, Intel Corporation -All rights reserved. This program and the accompanying materials are licensed and made available +Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -67,7 +67,7 @@ Returns: } BufferSize = sizeof (FAT_DIRECTORY_ENTRY); - return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry); + return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry, NULL); } EFI_STATUS @@ -116,7 +116,15 @@ Returns: // Write LFN directory entry // SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff); - StrCpy (LfnBuffer, DirEnt->FileString); + Status = StrCpyS ( + LfnBuffer, + sizeof (LfnBuffer) / sizeof (LfnBuffer[0]), + DirEnt->FileString + ); + if (EFI_ERROR (Status)) { + return Status; + } + LfnBufferPointer = LfnBuffer; LfnEntry.Attributes = FAT_ATTRIBUTE_LFN; LfnEntry.Type = 0; @@ -349,7 +357,11 @@ Returns: // Fail to get the long file name from long file name entry, // get the file name from short name // - FatGetFileNameViaCaseFlag (DirEnt, LfnBuffer); + FatGetFileNameViaCaseFlag ( + DirEnt, + LfnBuffer, + sizeof (LfnBuffer) / sizeof (LfnBuffer[0]) + ); } DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer); @@ -989,7 +1001,8 @@ Returns: // We will append this entry to the end of directory // FatGetCurrentFatTime (&DirEnt->Entry.FileCreateTime); - FatGetCurrentFatTime (&DirEnt->Entry.FileModificationTime); + CopyMem (&DirEnt->Entry.FileModificationTime, &DirEnt->Entry.FileCreateTime, sizeof (FAT_DATE_TIME)); + CopyMem (&DirEnt->Entry.FileLastAccess, &DirEnt->Entry.FileCreateTime.Date, sizeof (FAT_DATE)); NewEndPos = ODir->CurrentEndPos + DirEnt->EntryCount; if (NewEndPos * sizeof (FAT_DIRECTORY_ENTRY) > OFile->FileSize) { if (NewEndPos >= (OFile->IsFixedRootDir ? OFile->Volume->RootEntries : FAT_MAX_DIRENTRY_COUNT)) { @@ -1184,6 +1197,7 @@ Returns: FAT_ODIR *ODir; EFI_STATUS Status; + ASSERT (OFile != NULL); ODir = OFile->ODir; ASSERT (ODir != NULL); DirEnt = AllocateZeroPool (sizeof (FAT_DIRENT)); @@ -1375,8 +1389,8 @@ Returns: FAT_VOLUME *Volume; OFile = DirEnt->OFile; - Volume = OFile->Volume; ASSERT (OFile != NULL); + Volume = OFile->Volume; if (OFile->ODir != NULL) { FatDiscardODir (OFile); @@ -1440,6 +1454,8 @@ Returns: FAT_OFILE *OFile; FAT_DIRENT *DirEnt; + DirEnt = NULL; + FileNameLen = StrLen (FileName); if (FileNameLen == 0) { return EFI_INVALID_PARAMETER;