]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
Add code to check whether the pointer 'CorrectedPath' and 'FullPath' are NULL before...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Cp.c
index 087befd79028af2e49f427653291233a3410bd14..8fc263f6ba377ca79f24764a02612ea16a111759 100644 (file)
@@ -224,12 +224,23 @@ CopySingleFile(
       ASSERT(Buffer != NULL);\r
       while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) {\r
         Status = ShellReadFile(SourceHandle, &ReadSize, Buffer);\r
-        Status = ShellWriteFile(DestHandle, &ReadSize, Buffer);\r
+        if (!EFI_ERROR(Status)) {\r
+          Status = ShellWriteFile(DestHandle, &ReadSize, Buffer);\r
+          if (EFI_ERROR(Status)) {\r
+            ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, Dest);\r
+            break;\r
+          }\r
+        } else {\r
+          ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT));\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, Source);\r
+          break;\r
+        }\r
       }\r
     }\r
     SHELL_FREE_NON_NULL(DestVolumeInfo);\r
   }\r
-\r
+  \r
   //\r
   // close files\r
   //\r
@@ -286,7 +297,6 @@ ValidateAndCopyFiles(
   VOID                      *Response;\r
   UINTN                     PathLen;\r
   CONST CHAR16              *Cwd;\r
-  CONST CHAR16              *TempLocation;\r
   UINTN                     NewSize;\r
 \r
   if (Resp == NULL) {\r
@@ -479,7 +489,7 @@ ValidateAndCopyFiles(
       break;\r
     }\r
 \r
-    if ((TempLocation = StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName))) == 0\r
+    if ((StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName)) == 0)\r
       && (DestPath[StrLen(Node->FullName)] == CHAR_NULL || DestPath[StrLen(Node->FullName)] == L'\\')\r
       ) {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle);\r
@@ -552,7 +562,6 @@ ProcessValidateAndCopyFiles(
   } else if (List != NULL) {\r
     ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);\r
     ASSERT(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);\r
-    FileInfo    = NULL;\r
     FileInfo = gEfiShellProtocol->GetFileInfo(((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle);\r
     ASSERT(FileInfo != NULL);\r
     StrnCatGrow(&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0);\r