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>
This commit is contained in:
Hao Wu
2015-07-06 01:41:45 +00:00
committed by Jordan Justen
parent 4819b3e8f0
commit e76bc43e5d
4 changed files with 32 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2005 - 2014, 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
@@ -47,8 +47,12 @@ Returns:
{
UINT32 HashValue;
CHAR16 UpCasedLongFileName[EFI_PATH_STRING_LENGTH];
StrnCpy (UpCasedLongFileName, LongNameString, EFI_PATH_STRING_LENGTH - 1);
UpCasedLongFileName[EFI_PATH_STRING_LENGTH - 1] = L'\0';
StrnCpyS (
UpCasedLongFileName,
sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]),
LongNameString,
sizeof (UpCasedLongFileName) / sizeof (UpCasedLongFileName[0]) - 1
);
FatStrUpr (UpCasedLongFileName);
gBS->CalculateCrc32 (UpCasedLongFileName, StrSize (UpCasedLongFileName), &HashValue);
return (HashValue & HASH_TABLE_MASK);