X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ShellPkg%2FLibrary%2FUefiShellLevel2CommandsLib%2FCd.c;h=99680b49d9abf8f318e3e168f9e7161407ebd61a;hp=78403c22748bae815907aed756d1dd99a02a9047;hb=9ea69f8a05b808b4bab81b608436a02e2f2fba09;hpb=d38a107995ef90254713dcebf8f6bddb70183a1e;ds=sidebyside diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c index 78403c2274..99680b49d9 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c @@ -186,17 +186,27 @@ ShellCommandRunCd ( // change directory on other drive letter // Drive = AllocateZeroPool(StrSize(Param1)); - Drive = StrCpy(Drive, Param1); - Path = StrStr(Drive, L":"); - *(++Path) = CHAR_NULL; - Status = gEfiShellProtocol->SetCurDir(Drive, ++Path); + if (Drive == NULL) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle); + ShellStatus = SHELL_OUT_OF_RESOURCES; + } else { + Drive = StrCpy(Drive, Param1); + Path = StrStr(Drive, L":"); + *(++Path) = CHAR_NULL; + if (Path == Drive + StrLen(Drive)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle); + ShellStatus = SHELL_NOT_FOUND; + } else { + Status = gEfiShellProtocol->SetCurDir(Drive, ++Path); + } - if (Status == EFI_NOT_FOUND) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle); - Status = SHELL_NOT_FOUND; - } else if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1); - Status = SHELL_NOT_FOUND; + if (Status == EFI_NOT_FOUND) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CD_NF), gShellLevel2HiiHandle); + Status = SHELL_NOT_FOUND; + } else if (EFI_ERROR(Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, Param1); + Status = SHELL_NOT_FOUND; + } } } }