Get rid of calls to unsafe string functions. These are deprecated and may
be removed in the future.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
\r
\r
if ( *FileName != 0 ) {\r
\r
\r
if ( *FileName != 0 ) {\r
- AsciiStrToUnicodeStr (FileName, UnicodeFileName);\r
+ AsciiStrToUnicodeStrS (FileName, UnicodeFileName,\r
+ ARRAY_SIZE (UnicodeFileName));\r
- AsciiStrToUnicodeStr ("\\", UnicodeFileName);\r
+ AsciiStrToUnicodeStrS ("\\", UnicodeFileName, ARRAY_SIZE (UnicodeFileName));\r
}\r
\r
Size = StrSize (UnicodeFileName);\r
}\r
\r
Size = StrSize (UnicodeFileName);\r
&AuthenticationStatus\r
);\r
if (!EFI_ERROR (Status)) {\r
&AuthenticationStatus\r
);\r
if (!EFI_ERROR (Status)) {\r
- UnicodeStrToAsciiStr (Section, AsciiSection);\r
+ UnicodeStrToAsciiStrS (Section, AsciiSection, MAX_PATHNAME);\r
if (AsciiStriCmp (FileName, AsciiSection) == 0) {\r
FreePool (Section);\r
break;\r
if (AsciiStriCmp (FileName, AsciiSection) == 0) {\r
FreePool (Section);\r
break;\r
CHAR8 *CwdPlusPathName;\r
UINTN Index;\r
EFI_SECTION_TYPE ModifiedSectionType;\r
CHAR8 *CwdPlusPathName;\r
UINTN Index;\r
EFI_SECTION_TYPE ModifiedSectionType;\r
\r
EblUpdateDeviceLists ();\r
\r
\r
EblUpdateDeviceLists ();\r
\r
}\r
\r
// We could add a current working directory concept\r
}\r
\r
// We could add a current working directory concept\r
- CwdPlusPathName = AllocatePool (AsciiStrSize (gCwd) + AsciiStrSize (PathName));\r
+ AsciiLength = AsciiStrSize (gCwd) + AsciiStrSize (PathName);\r
+ CwdPlusPathName = AllocatePool (AsciiLength);\r
if (CwdPlusPathName == NULL) {\r
return NULL;\r
}\r
if (CwdPlusPathName == NULL) {\r
return NULL;\r
}\r
- AsciiStrCpy (CwdPlusPathName, gCwd);\r
+ AsciiStrCpyS (CwdPlusPathName, AsciiLength, gCwd);\r
StrLen = AsciiStrLen (gCwd);\r
if ((*PathName != '/') && (*PathName != '\\') && (gCwd[StrLen-1] != '/') && (gCwd[StrLen-1] != '\\')) {\r
StrLen = AsciiStrLen (gCwd);\r
if ((*PathName != '/') && (*PathName != '\\') && (gCwd[StrLen-1] != '/') && (gCwd[StrLen-1] != '\\')) {\r
- AsciiStrCat (CwdPlusPathName, "\\");\r
+ AsciiStrCatS (CwdPlusPathName, AsciiLength, "\\");\r
- AsciiStrCat (CwdPlusPathName, PathName);\r
+ AsciiStrCatS (CwdPlusPathName, AsciiLength, PathName);\r
if (AsciiStrStr (CwdPlusPathName, ":") == NULL) {\r
// Extra error check to make sure we don't recurse and blow stack\r
return NULL;\r
if (AsciiStrStr (CwdPlusPathName, ":") == NULL) {\r
// Extra error check to make sure we don't recurse and blow stack\r
return NULL;\r
}\r
\r
File->DeviceName = AllocatePool (StrLen);\r
}\r
\r
File->DeviceName = AllocatePool (StrLen);\r
- AsciiStrCpy (File->DeviceName, PathName);\r
+ AsciiStrCpyS (File->DeviceName, StrLen, PathName);\r
File->DeviceName[FileStart - 1] = '\0';\r
File->FileName = &File->DeviceName[FileStart];\r
if (File->FileName[0] == '\0') {\r
File->DeviceName[FileStart - 1] = '\0';\r
File->FileName = &File->DeviceName[FileStart];\r
if (File->FileName[0] == '\0') {\r
{\r
CHAR8 *NewPath;\r
CHAR8 *Work, *Start, *End;\r
{\r
CHAR8 *NewPath;\r
CHAR8 *Work, *Start, *End;\r
+ UINTN StrLen, AllocLen;\r
INTN i;\r
\r
if (Cwd == NULL || Path == NULL) {\r
INTN i;\r
\r
if (Cwd == NULL || Path == NULL) {\r
}\r
\r
StrLen = AsciiStrSize (Path);\r
}\r
\r
StrLen = AsciiStrSize (Path);\r
- NewPath = AllocatePool (AsciiStrSize (Cwd) + StrLen + 1);\r
+ AllocLen = AsciiStrSize (Cwd) + StrLen + 1;\r
+ NewPath = AllocatePool (AllocLen);\r
if (NewPath == NULL) {\r
return NULL;\r
}\r
if (NewPath == NULL) {\r
return NULL;\r
}\r
- AsciiStrCpy (NewPath, Cwd);\r
+ AsciiStrCpyS (NewPath, AllocLen, Cwd);\r
\r
End = Path + StrLen;\r
for (Start = Path ;;) {\r
\r
End = Path + StrLen;\r
for (Start = Path ;;) {\r
}\r
\r
// append path prior to ..\r
}\r
\r
// append path prior to ..\r
- AsciiStrnCat (NewPath, Start, Work - Start);\r
+ AsciiStrnCatS (NewPath, AllocLen, Start, Work - Start);\r
StrLen = AsciiStrLen (NewPath);\r
for (i = StrLen; i >= 0; i--) {\r
if (NewPath[i] == ':') {\r
StrLen = AsciiStrLen (NewPath);\r
for (i = StrLen; i >= 0; i--) {\r
if (NewPath[i] == ':') {\r
}\r
\r
// Handle the path that remains after the ..\r
}\r
\r
// Handle the path that remains after the ..\r
- AsciiStrnCat (NewPath, Start, End - Start);\r
+ AsciiStrnCatS (NewPath, AllocLen, Start, End - Start);\r
)\r
{\r
EFI_OPEN_FILE *File;\r
)\r
{\r
EFI_OPEN_FILE *File;\r
CHAR8 *Path;\r
\r
if (Cwd == NULL) {\r
CHAR8 *Path;\r
\r
if (Cwd == NULL) {\r
\r
// Use the info returned from EfiOpen as it can add in CWD if needed. So Cwd could be\r
// relative to the current gCwd or not.\r
\r
// Use the info returned from EfiOpen as it can add in CWD if needed. So Cwd could be\r
// relative to the current gCwd or not.\r
- gCwd = AllocatePool (AsciiStrSize (File->DeviceName) + AsciiStrSize (File->FileName) + 10);\r
+ AllocLen = AsciiStrSize (File->DeviceName) + AsciiStrSize (File->FileName) + 10;\r
+ gCwd = AllocatePool (AllocLen);\r
if (gCwd == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
if (gCwd == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
\r
- AsciiStrCpy (gCwd, File->DeviceName);\r
+ AsciiStrCpyS (gCwd, AllocLen, File->DeviceName);\r
if (File->FileName == NULL) {\r
if (File->FileName == NULL) {\r
- AsciiStrCat (gCwd, ":\\");\r
+ AsciiStrCatS (gCwd, AllocLen, ":\\");\r
- AsciiStrCat (gCwd, ":");\r
- AsciiStrCat (gCwd, File->FileName);\r
+ AsciiStrCatS (gCwd, AllocLen, ":");\r
+ AsciiStrCatS (gCwd, AllocLen, File->FileName);\r