summaryrefslogtreecommitdiffstats
path: root/FatPkg/EnhancedFatDxe/DirectoryManage.c
diff options
context:
space:
mode:
authorHao Wu <hao.a.wu@intel.com>2015-07-06 01:41:45 +0000
committerJordan Justen <jordan.l.justen@intel.com>2016-04-06 23:22:43 -0700
commite76bc43e5d5827e7f8b20b3f89727b9bc86395e8 (patch)
treec37edfc048ffa4d1086fd43c9e810af9a59a8bcb /FatPkg/EnhancedFatDxe/DirectoryManage.c
parent4819b3e8f01e8d61ba5310d9de6ce71598d5b54c (diff)
downloadedk2-e76bc43e5d5827e7f8b20b3f89727b9bc86395e8.tar.gz
edk2-e76bc43e5d5827e7f8b20b3f89727b9bc86395e8.tar.bz2
edk2-e76bc43e5d5827e7f8b20b3f89727b9bc86395e8.zip
FatPkg EnhancedFatDxe: Use safe string functions
Unsafe string functions are replaced with safe ones. Safe string functions will assert if DestMax is not greater than StrnLenS(Source, DestMax). Therefore, additional assert for checking the size of source and destination buffers can be removed. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> (based on FatPkg commit 2cb92b4f19b096daf133d6501afa13e5a85062c5) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Acked-by: Mark Doran <mark.doran@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'FatPkg/EnhancedFatDxe/DirectoryManage.c')
-rw-r--r--FatPkg/EnhancedFatDxe/DirectoryManage.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c b/FatPkg/EnhancedFatDxe/DirectoryManage.c
index 116f87a4c2..91e7599e27 100644
--- a/FatPkg/EnhancedFatDxe/DirectoryManage.c
+++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
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
@@ -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);