]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: add verification that a target directory exists when changing directory...
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 13 Feb 2013 22:22:16 +0000 (22:22 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 13 Feb 2013 22:22:16 +0000 (22:22 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14128 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c

index 74beb093c41de42e91c6398fb3ebf96a612922c2..c0d3c920f492fb70f332c59a26a14b2022c6b37f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for attrib shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -149,6 +149,9 @@ ShellCommandRunCd (
             }\r
           }\r
         } else if (StrStr(Param1Copy, L":") == NULL) {\r
+          //\r
+          // change directory without a drive identifier\r
+          //\r
           if (ShellGetCurrentDir(NULL) == NULL) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);\r
             ShellStatus = SHELL_NOT_FOUND;\r
@@ -189,7 +192,7 @@ ShellCommandRunCd (
           }\r
         } else {\r
           //\r
-          // change directory on other drive letter\r
+          // change directory with a drive letter\r
           //\r
           Drive = AllocateZeroPool(StrSize(Param1Copy));\r
           if (Drive == NULL) {\r
@@ -199,7 +202,10 @@ ShellCommandRunCd (
             Drive = StrCpy(Drive, Param1Copy);\r
             Path = StrStr(Drive, L":");\r
             ASSERT(Path != NULL);\r
-            if (*(Path+1) == CHAR_NULL) {\r
+            if (EFI_ERROR(ShellIsDirectory(Param1Copy))) {\r
+              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, Param1Copy);\r
+              ShellStatus = SHELL_NOT_FOUND;\r
+            } else if (*(Path+1) == CHAR_NULL) {\r
               ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle);\r
               ShellStatus = SHELL_NOT_FOUND;\r
             } else {\r