From bd8504381c8acf81d4abfe252751a2d93ae97d0d Mon Sep 17 00:00:00 2001 From: Qiu Shumin Date: Fri, 18 Dec 2015 07:28:26 +0000 Subject: ShellPkg: Use safe string functions to refine 'Tftp.c' code. Safe string functions can help avoid potential buffer overflow. This patch replaces the StrCpy with StCpyS. (Sync patch r18608 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qiu Shumin Reviewed-by: Jaben Carsey git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19393 6f19259b-4bc3-4df7-8a09-765794883524 --- ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c index 4bb21aae6f..02099febef 100644 --- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c +++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c @@ -955,6 +955,7 @@ CheckPacket ( UINTN Index; UINTN LastStep; UINTN Step; + EFI_STATUS Status; if ((NTOHS (Packet->OpCode)) != EFI_MTFTP4_OPCODE_DATA) { return EFI_SUCCESS; @@ -984,7 +985,10 @@ CheckPacket ( ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete); - StrCpy (Progress, mTftpProgressFrame); + Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame); + if (EFI_ERROR(Status)) { + return Status; + } for (Index = 1; Index < Step; Index++) { Progress[Index] = L'='; } -- cgit v1.2.3