]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Use safe string functions to refine 'Tftp.c' code.
authorQiu Shumin <shumin.qiu@intel.com>
Thu, 15 Oct 2015 02:19:14 +0000 (02:19 +0000)
committershenshushi <shenshushi@Edk2>
Thu, 15 Oct 2015 02:19:14 +0000 (02:19 +0000)
Safe string functions can help avoid potential buffer overflow. This patch replaces the StrCpy with StCpyS.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18608 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c

index 4bb21aae6fb67ba333a9b5e28a5adf5c8612eee6..02099febef08358fa99846fe2e30019894980192 100644 (file)
@@ -955,6 +955,7 @@ CheckPacket (
   UINTN             Index;\r
   UINTN             LastStep;\r
   UINTN             Step;\r
+  EFI_STATUS        Status;\r
 \r
   if ((NTOHS (Packet->OpCode)) != EFI_MTFTP4_OPCODE_DATA) {\r
     return EFI_SUCCESS;\r
@@ -984,7 +985,10 @@ CheckPacket (
 \r
   ShellPrintEx (-1, -1, L"%s", mTftpProgressDelete);\r
 \r
-  StrCpy (Progress, mTftpProgressFrame);\r
+  Status = StrCpyS (Progress, TFTP_PROGRESS_MESSAGE_SIZE, mTftpProgressFrame);\r
+  if (EFI_ERROR(Status)) {\r
+    return Status;\r
+  }\r
   for (Index = 1; Index < Step; Index++) {\r
     Progress[Index] = L'=';\r
   }\r