mirror of https://github.com/acidanthera/audk.git
EmbeddedPkg/AndroidFastboot: eliminate deprecated string function calls
Get rid of calls to unsafe string functions. These are deprecated and may be removed in the future. Note that this also addresses a latent potential issue in HandleDownload(), where NumBytesString[] (which comes from the wire) is assumed to contain a string representation of a number with all the significant digits in the first 8 bytes, which is not guaranteed by the protocol. 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
15d8747a5f
commit
310908760f
|
@ -84,7 +84,8 @@ ParseAndroidBootImg (
|
||||||
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize));
|
+ ALIGN_VALUE (Header->KernelSize, Header->PageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
AsciiStrnCpy (KernelArgs, Header->KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE);
|
AsciiStrnCpyS (KernelArgs, BOOTIMG_KERNEL_ARGS_SIZE, Header->KernelArgs,
|
||||||
|
BOOTIMG_KERNEL_ARGS_SIZE);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ HandleDownload (
|
||||||
IN CHAR8 *NumBytesString
|
IN CHAR8 *NumBytesString
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CHAR8 Response[12] = "DATA";
|
CHAR8 Response[13];
|
||||||
CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
|
CHAR16 OutputString[FASTBOOT_STRING_MAX_LENGTH];
|
||||||
|
|
||||||
// Argument is 8-character ASCII string hex representation of number of bytes
|
// Argument is 8-character ASCII string hex representation of number of bytes
|
||||||
|
@ -127,8 +127,10 @@ HandleDownload (
|
||||||
if (mDataBuffer == NULL) {
|
if (mDataBuffer == NULL) {
|
||||||
SEND_LITERAL ("FAILNot enough memory");
|
SEND_LITERAL ("FAILNot enough memory");
|
||||||
} else {
|
} else {
|
||||||
AsciiStrnCpy (Response + 4, NumBytesString, 8);
|
ZeroMem (Response, sizeof Response);
|
||||||
mTransport->Send (sizeof(Response), Response, &mFatalSendErrorEvent);
|
AsciiSPrint (Response, sizeof Response, "DATA%x",
|
||||||
|
(UINT32)mNumDataBytes);
|
||||||
|
mTransport->Send (sizeof Response - 1, Response, &mFatalSendErrorEvent);
|
||||||
|
|
||||||
mState = ExpectDataState;
|
mState = ExpectDataState;
|
||||||
mBytesReceivedSoFar = 0;
|
mBytesReceivedSoFar = 0;
|
||||||
|
@ -257,8 +259,7 @@ AcceptCmd (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commands aren't null-terminated. Let's get a null-terminated version.
|
// Commands aren't null-terminated. Let's get a null-terminated version.
|
||||||
AsciiStrnCpy (Command, Data, Size);
|
AsciiStrnCpyS (Command, sizeof Command, Data, Size);
|
||||||
Command[Size] = '\0';
|
|
||||||
|
|
||||||
// Parse command
|
// Parse command
|
||||||
if (MATCH_CMD_LITERAL ("getvar", Command)) {
|
if (MATCH_CMD_LITERAL ("getvar", Command)) {
|
||||||
|
|
Loading…
Reference in New Issue