mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 08:04:07 +02:00
EmbeddedPkg/Ebl: eliminate deprecated string function calls
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>
This commit is contained in:
parent
310908760f
commit
5140a6dfb9
@ -614,7 +614,7 @@ OutputData (
|
|||||||
UINTN Spaces = 0;
|
UINTN Spaces = 0;
|
||||||
CHAR8 Blanks[80];
|
CHAR8 Blanks[80];
|
||||||
|
|
||||||
AsciiStrCpy (Blanks, mBlanks);
|
AsciiStrCpyS (Blanks, sizeof Blanks, mBlanks);
|
||||||
for (EndAddress = Address + Length; Address < EndAddress; Offset += Line) {
|
for (EndAddress = Address + Length; Address < EndAddress; Offset += Line) {
|
||||||
AsciiPrint ("%08x: ", Offset);
|
AsciiPrint ("%08x: ", Offset);
|
||||||
for (Line = 0; (Line < 0x10) && (Address < EndAddress);) {
|
for (Line = 0; (Line < 0x10) && (Address < EndAddress);) {
|
||||||
|
@ -116,7 +116,8 @@ EblDirCmd (
|
|||||||
UnicodeFileName[0] = '\0';
|
UnicodeFileName[0] = '\0';
|
||||||
MatchSubString = &UnicodeFileName[0];
|
MatchSubString = &UnicodeFileName[0];
|
||||||
if (Argc > 2) {
|
if (Argc > 2) {
|
||||||
AsciiStrToUnicodeStr (Argv[2], UnicodeFileName);
|
AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName,
|
||||||
|
ARRAY_SIZE (UnicodeFileName));
|
||||||
if (UnicodeFileName[0] == '*') {
|
if (UnicodeFileName[0] == '*') {
|
||||||
// Handle *Name substring matching
|
// Handle *Name substring matching
|
||||||
MatchSubString = &UnicodeFileName[1];
|
MatchSubString = &UnicodeFileName[1];
|
||||||
@ -231,7 +232,7 @@ EblDirCmd (
|
|||||||
MatchSubString = NULL;
|
MatchSubString = NULL;
|
||||||
UnicodeFileName[0] = '\0';
|
UnicodeFileName[0] = '\0';
|
||||||
if (Argc > 2) {
|
if (Argc > 2) {
|
||||||
AsciiStrToUnicodeStr (Argv[2], UnicodeFileName);
|
AsciiStrToUnicodeStrS (Argv[2], UnicodeFileName, MAX_CMD_LINE);
|
||||||
if (UnicodeFileName[0] == '*') {
|
if (UnicodeFileName[0] == '*') {
|
||||||
MatchSubString = &UnicodeFileName[1];
|
MatchSubString = &UnicodeFileName[1];
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ EblStartCmd (
|
|||||||
|
|
||||||
ImageInfo->LoadOptionsSize = (UINT32)AsciiStrSize (Argv[2]);
|
ImageInfo->LoadOptionsSize = (UINT32)AsciiStrSize (Argv[2]);
|
||||||
ImageInfo->LoadOptions = AllocatePool (ImageInfo->LoadOptionsSize);
|
ImageInfo->LoadOptions = AllocatePool (ImageInfo->LoadOptionsSize);
|
||||||
AsciiStrCpy (ImageInfo->LoadOptions, Argv[2]);
|
AsciiStrCpyS (ImageInfo->LoadOptions, ImageInfo->LoadOptionsSize, Argv[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer control to the EFI image we loaded with LoadImage()
|
// Transfer control to the EFI image we loaded with LoadImage()
|
||||||
@ -741,7 +741,7 @@ EblFileCopyCmd (
|
|||||||
UINTN Size;
|
UINTN Size;
|
||||||
UINTN Offset;
|
UINTN Offset;
|
||||||
UINTN Chunk = FILE_COPY_CHUNK;
|
UINTN Chunk = FILE_COPY_CHUNK;
|
||||||
UINTN FileNameLen;
|
UINTN FileNameLen, DestFileNameLen;
|
||||||
CHAR8* DestFileName;
|
CHAR8* DestFileName;
|
||||||
CHAR8* SrcFileName;
|
CHAR8* SrcFileName;
|
||||||
CHAR8* SrcPtr;
|
CHAR8* SrcPtr;
|
||||||
@ -786,9 +786,10 @@ EblFileCopyCmd (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct the destination filepath
|
// Construct the destination filepath
|
||||||
DestFileName = (CHAR8*)AllocatePool (FileNameLen + AsciiStrLen (SrcFileName) + 1);
|
DestFileNameLen = FileNameLen + AsciiStrLen (SrcFileName) + 1;
|
||||||
AsciiStrCpy (DestFileName, Argv[2]);
|
DestFileName = (CHAR8*)AllocatePool (DestFileNameLen);
|
||||||
AsciiStrCat (DestFileName, SrcFileName);
|
AsciiStrCpyS (DestFileName, DestFileNameLen, Argv[2]);
|
||||||
|
AsciiStrCatS (DestFileName, DestFileNameLen, SrcFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
|
Source = EfiOpen(Argv[1], EFI_FILE_MODE_READ, 0);
|
||||||
|
@ -88,7 +88,7 @@ SetCmdHistory (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy the new command line into the ring buffer
|
// Copy the new command line into the ring buffer
|
||||||
AsciiStrnCpy(&mCmdHistory[mCmdHistoryStart][0], Cmd, MAX_CMD_LINE);
|
AsciiStrnCpyS (&mCmdHistory[mCmdHistoryStart][0], MAX_CMD_LINE, Cmd, MAX_CMD_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the command history for the next up arrow press
|
// Reset the command history for the next up arrow press
|
||||||
@ -432,7 +432,7 @@ GetCmd (
|
|||||||
}
|
}
|
||||||
AsciiPrint (History);
|
AsciiPrint (History);
|
||||||
Index = AsciiStrLen (History);
|
Index = AsciiStrLen (History);
|
||||||
AsciiStrnCpy (Cmd, History, CmdMaxSize);
|
AsciiStrnCpyS (Cmd, CmdMaxSize, History, CmdMaxSize);
|
||||||
} else {
|
} else {
|
||||||
Cmd[Index++] = Char;
|
Cmd[Index++] = Char;
|
||||||
if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {
|
if (FixedPcdGetBool(PcdEmbeddedShellCharacterEcho) == TRUE) {
|
||||||
@ -644,14 +644,14 @@ EdkBootLoaderEntry (
|
|||||||
|
|
||||||
Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);
|
Status = gRT->GetVariable(CommandLineVariableName, &VendorGuid, NULL, &CommandLineVariableSize, CommandLineVariable);
|
||||||
if (!EFI_ERROR(Status)) {
|
if (!EFI_ERROR(Status)) {
|
||||||
UnicodeStrToAsciiStr(CommandLineVariable, CmdLine);
|
UnicodeStrToAsciiStrS (CommandLineVariable, CmdLine, MAX_CMD_LINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool(CommandLineVariable);
|
FreePool(CommandLineVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
AsciiStrCpy (CmdLine, (CHAR8 *)PcdGetPtr (PcdEmbeddedAutomaticBootCommand));
|
AsciiStrCpyS (CmdLine, MAX_CMD_LINE, (CHAR8 *)PcdGetPtr (PcdEmbeddedAutomaticBootCommand));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -29,6 +29,7 @@ EblGetCmd (
|
|||||||
VOID* Value;
|
VOID* Value;
|
||||||
CHAR8* AsciiVariableName = NULL;
|
CHAR8* AsciiVariableName = NULL;
|
||||||
CHAR16* VariableName;
|
CHAR16* VariableName;
|
||||||
|
UINTN VariableNameLen;
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
|
|
||||||
if (Argc == 1) {
|
if (Argc == 1) {
|
||||||
@ -48,8 +49,9 @@ EblGetCmd (
|
|||||||
AsciiPrint("Variable name is missing.\n");
|
AsciiPrint("Variable name is missing.\n");
|
||||||
return Status;
|
return Status;
|
||||||
} else {
|
} else {
|
||||||
VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
|
VariableNameLen = AsciiStrLen (AsciiVariableName) + 1;
|
||||||
AsciiStrToUnicodeStr (AsciiVariableName,VariableName);
|
VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));
|
||||||
|
AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get the variable size.
|
// Try to get the variable size.
|
||||||
@ -93,6 +95,7 @@ EblSetCmd (
|
|||||||
CHAR8* AsciiValue;
|
CHAR8* AsciiValue;
|
||||||
UINT32 AsciiValueLength;
|
UINT32 AsciiValueLength;
|
||||||
CHAR16* VariableName;
|
CHAR16* VariableName;
|
||||||
|
UINTN VariableNameLen;
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
UINT32 EscapedQuotes = 0;
|
UINT32 EscapedQuotes = 0;
|
||||||
BOOLEAN Volatile = FALSE;
|
BOOLEAN Volatile = FALSE;
|
||||||
@ -125,8 +128,9 @@ EblSetCmd (
|
|||||||
//
|
//
|
||||||
|
|
||||||
// Convert VariableName into Unicode
|
// Convert VariableName into Unicode
|
||||||
VariableName = AllocatePool((AsciiStrLen (AsciiVariableSetting) + 1) * sizeof (CHAR16));
|
VariableNameLen = AsciiStrLen (AsciiVariableSetting) + 1;
|
||||||
AsciiStrToUnicodeStr (AsciiVariableSetting,VariableName);
|
VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));
|
||||||
|
AsciiStrToUnicodeStrS (AsciiVariableSetting, VariableName, VariableNameLen);
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
VariableName,
|
VariableName,
|
||||||
@ -170,8 +174,9 @@ EblSetCmd (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert VariableName into Unicode
|
// Convert VariableName into Unicode
|
||||||
VariableName = AllocatePool((AsciiStrLen (AsciiVariableName) + 1) * sizeof (CHAR16));
|
VariableNameLen = AsciiStrLen (AsciiVariableName) + 1;
|
||||||
AsciiStrToUnicodeStr (AsciiVariableName,VariableName);
|
VariableName = AllocatePool (VariableNameLen * sizeof (CHAR16));
|
||||||
|
AsciiStrToUnicodeStrS (AsciiVariableName, VariableName, VariableNameLen);
|
||||||
|
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
VariableName,
|
VariableName,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user