]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
ShellPkg: Verify memory allocations without ASSERT.
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Mv.c
index b83eede5a90cec90289a1854fa5438931b6b1afe..a93ef33c039c02dd602add040a5ac28855b8ee59 100644 (file)
@@ -120,9 +120,10 @@ IsValidMove(
   @param[in, out] DestPathPointer  A pointer to the callee allocated final path.\r
   @param[in] Cwd                   A pointer to the current working directory.\r
 \r
-  @retval EFI_INVALID_PARAMETR  The DestDir could not be resolved to a location.\r
-  @retval EFI_INVALID_PARAMETR  The DestDir could be resolved to more than 1 location.\r
-  @retval EFI_SUCCESS           The operation was sucessful.\r
+  @retval SHELL_INVALID_PARAMETER  The DestDir could not be resolved to a location.\r
+  @retval SHELL_INVALID_PARAMETER  The DestDir could be resolved to more than 1 location.\r
+  @retval SHELL_INVALID_PARAMETER  Cwd is required and is NULL.\r
+  @retval SHELL_SUCCESS            The operation was sucessful.\r
 **/\r
 SHELL_STATUS\r
 EFIAPI\r
@@ -143,6 +144,9 @@ GetDestinationLocation(
   DestPath = NULL;\r
 \r
   if (StrStr(DestDir, L"\\") == DestDir) {\r
+    if (Cwd == NULL) {\r
+      return SHELL_INVALID_PARAMETER;\r
+    }\r
     DestPath = AllocateZeroPool(StrSize(Cwd));\r
     if (DestPath == NULL) {\r
       return (SHELL_OUT_OF_RESOURCES);\r
@@ -161,6 +165,10 @@ GetDestinationLocation(
     // Not existing... must be renaming\r
     //\r
     if ((TempLocation = StrStr(DestDir, L":")) == NULL) {\r
+      if (Cwd == NULL) {\r
+        ShellCloseFileMetaArg(&DestList);\r
+        return (SHELL_INVALID_PARAMETER);\r
+      }\r
       NewSize = StrSize(Cwd);\r
       NewSize += StrSize(DestDir);\r
       DestPath = AllocateZeroPool(NewSize);\r