]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLib/UefiShellLib.c
ShellPkg: Code refine. Add error handling code to check pointer and remove redundant...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLib / UefiShellLib.c
index 40b87fec34e99ece7ad32cb7f32db0fdcb7114a8..b7ca41b9846b65bb5c91267b5d91a2a7dbb30f5f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2014, 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
@@ -1175,7 +1175,7 @@ ShellSetEnvironmentVariable (
   The CommandLine is executed from the current working directory on the current\r
   device.\r
 \r
-  The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0\r
+  The EnvironmentVariables pararemeter is ignored in a pre-UEFI Shell 2.0\r
   environment.  The values pointed to by the parameters will be unchanged by the\r
   ShellExecute() function.  The Output parameter has no effect in a\r
   UEFI Shell 2.0 environment.\r
@@ -1203,6 +1203,7 @@ ShellExecute (
   OUT EFI_STATUS                *Status OPTIONAL\r
   )\r
 {\r
+  EFI_STATUS                CmdStatus;\r
   //\r
   // Check for UEFI Shell 2.0 protocols\r
   //\r
@@ -1221,16 +1222,29 @@ ShellExecute (
   //\r
   if (mEfiShellEnvironment2 != NULL) {\r
     //\r
-    // Call EFI Shell version (not using EnvironmentVariables or Status parameters)\r
+    // Call EFI Shell version.\r
     // Due to oddity in the EFI shell we want to dereference the ParentHandle here\r
     //\r
-    return (mEfiShellEnvironment2->Execute(*ParentHandle,\r
+    CmdStatus = (mEfiShellEnvironment2->Execute(*ParentHandle,\r
                                           CommandLine,\r
                                           Output));\r
+    //\r
+    // No Status output parameter so just use the returned status\r
+    //\r
+    if (Status != NULL) {\r
+      *Status = CmdStatus;\r
+    }\r
+    //\r
+    // If there was an error, we can't tell if it was from the command or from\r
+    // the Execute() function, so we'll just assume the shell ran successfully\r
+    // and the error came from the command.\r
+    //\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   return (EFI_UNSUPPORTED);\r
 }\r
+\r
 /**\r
   Retreives the current directory path\r
 \r
@@ -1416,26 +1430,30 @@ InternalShellConvertFileListType (
     //\r
     // allocate new space to copy strings and structure\r
     //\r
-    NewInfo->FullName     = AllocateZeroPool(StrSize(OldInfo->FullName));\r
-    NewInfo->FileName     = AllocateZeroPool(StrSize(OldInfo->FileName));\r
-    NewInfo->Info         = AllocateZeroPool((UINTN)OldInfo->Info->Size);\r
+    NewInfo->FullName     = AllocateCopyPool(StrSize(OldInfo->FullName), OldInfo->FullName);\r
+    NewInfo->FileName     = AllocateCopyPool(StrSize(OldInfo->FileName), OldInfo->FileName);\r
+    NewInfo->Info         = AllocateCopyPool((UINTN)OldInfo->Info->Size, OldInfo->Info);\r
 \r
     //\r
     // make sure all the memory allocations were sucessful\r
     //\r
     if (NULL == NewInfo->FullName || NewInfo->FileName == NULL || NewInfo->Info == NULL) {\r
+      //\r
+      // Free the partially allocated new node\r
+      //\r
+      SHELL_FREE_NON_NULL(NewInfo->FullName);\r
+      SHELL_FREE_NON_NULL(NewInfo->FileName);\r
+      SHELL_FREE_NON_NULL(NewInfo->Info);\r
+      SHELL_FREE_NON_NULL(NewInfo);\r
+\r
+      //\r
+      // Free the previously converted stuff\r
+      //\r
       ShellCloseFileMetaArg((EFI_SHELL_FILE_INFO**)(&ListHead));\r
       ListHead = NULL;\r
       break;\r
     }\r
 \r
-    //\r
-    // Copt the strings and structure\r
-    //\r
-    StrCpy(NewInfo->FullName, OldInfo->FullName);\r
-    StrCpy(NewInfo->FileName, OldInfo->FileName);\r
-    gBS->CopyMem (NewInfo->Info, OldInfo->Info, (UINTN)OldInfo->Info->Size);\r
-\r
     //\r
     // add that to the list\r
     //\r
@@ -1447,8 +1465,8 @@ InternalShellConvertFileListType (
   Opens a group of files based on a path.\r
 \r
   This function uses the Arg to open all the matching files. Each matched\r
-  file has a SHELL_FILE_ARG structure to record the file information. These\r
-  structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG\r
+  file has a SHELL_FILE_INFO structure to record the file information. These\r
+  structures are placed on the list ListHead. Users can get the SHELL_FILE_INFO\r
   structures from ListHead to access each file. This function supports wildcards\r
   and will process '?' and '*' as such.  the list must be freed with a call to\r
   ShellCloseFileMetaArg().\r
@@ -1476,6 +1494,7 @@ ShellOpenFileMetaArg (
 {\r
   EFI_STATUS                    Status;\r
   LIST_ENTRY                    mOldStyleFileList;\r
+  CHAR16                        *CleanFilePathStr;\r
 \r
   //\r
   // ASSERT that Arg and ListHead are not NULL\r
@@ -1483,6 +1502,13 @@ ShellOpenFileMetaArg (
   ASSERT(Arg      != NULL);\r
   ASSERT(ListHead != NULL);\r
 \r
+  CleanFilePathStr = NULL;\r
+\r
+  Status = InternalShellStripQuotes (Arg, &CleanFilePathStr);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Check for UEFI Shell 2.0 protocols\r
   //\r
@@ -1490,11 +1516,12 @@ ShellOpenFileMetaArg (
     if (*ListHead == NULL) {\r
       *ListHead = (EFI_SHELL_FILE_INFO*)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
       if (*ListHead == NULL) {\r
+        FreePool(CleanFilePathStr);\r
         return (EFI_OUT_OF_RESOURCES);\r
       }\r
       InitializeListHead(&((*ListHead)->Link));\r
     }\r
-    Status = gEfiShellProtocol->OpenFileList(Arg,\r
+    Status = gEfiShellProtocol->OpenFileList(CleanFilePathStr,\r
                                            OpenMode,\r
                                            ListHead);\r
     if (EFI_ERROR(Status)) {\r
@@ -1504,9 +1531,11 @@ ShellOpenFileMetaArg (
     }\r
     if (*ListHead != NULL && IsListEmpty(&(*ListHead)->Link)) {\r
       FreePool(*ListHead);\r
+      FreePool(CleanFilePathStr);\r
       *ListHead = NULL;\r
       return (EFI_NOT_FOUND);\r
     }\r
+    FreePool(CleanFilePathStr);\r
     return (Status);\r
   }\r
 \r
@@ -1522,15 +1551,17 @@ ShellOpenFileMetaArg (
     //\r
     // Get the EFI Shell list of files\r
     //\r
-    Status = mEfiShellEnvironment2->FileMetaArg(Arg, &mOldStyleFileList);\r
+    Status = mEfiShellEnvironment2->FileMetaArg(CleanFilePathStr, &mOldStyleFileList);\r
     if (EFI_ERROR(Status)) {\r
       *ListHead = NULL;\r
+      FreePool(CleanFilePathStr);\r
       return (Status);\r
     }\r
 \r
     if (*ListHead == NULL) {\r
       *ListHead = (EFI_SHELL_FILE_INFO    *)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
       if (*ListHead == NULL) {\r
+        FreePool(CleanFilePathStr);\r
         return (EFI_OUT_OF_RESOURCES);\r
       }\r
       InitializeListHead(&((*ListHead)->Link));\r
@@ -1551,9 +1582,11 @@ ShellOpenFileMetaArg (
       *ListHead = NULL;\r
       Status = EFI_NOT_FOUND;\r
     }\r
+    FreePool(CleanFilePathStr);\r
     return (Status);\r
   }\r
 \r
+  FreePool(CleanFilePathStr);\r
   return (EFI_UNSUPPORTED);\r
 }\r
 /**\r
@@ -1598,6 +1631,7 @@ ShellCloseFileMetaArg (
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Info);\r
       FreePool((EFI_SHELL_FILE_INFO_NO_CONST*)Node);\r
     }\r
+    SHELL_FREE_NON_NULL(*ListHead);\r
     return EFI_SUCCESS;\r
   }\r
 \r
@@ -1656,8 +1690,8 @@ ShellFindFilePath (
     if (TestPath == NULL) {\r
       return (NULL);\r
     }\r
-    StrCpy(TestPath, Path);\r
-    StrCat(TestPath, FileName);\r
+    StrnCpy(TestPath, Path, Size/sizeof(CHAR16) - 1);\r
+    StrnCat(TestPath, FileName, Size/sizeof(CHAR16) - 1 - StrLen(TestPath));\r
     Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
     if (!EFI_ERROR(Status)){\r
       if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {\r
@@ -1689,12 +1723,12 @@ ShellFindFilePath (
           *TempChar = CHAR_NULL;\r
         }\r
         if (TestPath[StrLen(TestPath)-1] != L'\\') {\r
-          StrCat(TestPath, L"\\");\r
+          StrnCat(TestPath, L"\\", Size/sizeof(CHAR16) - 1 - StrLen(TestPath));\r
         }\r
         if (FileName[0] == L'\\') {\r
           FileName++;\r
         }\r
-        StrCat(TestPath, FileName);\r
+        StrnCat(TestPath, FileName, Size/sizeof(CHAR16) - 1 - StrLen(TestPath));\r
         if (StrStr(Walker, L";") != NULL) {\r
           Walker = StrStr(Walker, L";") + 1;\r
         } else {\r
@@ -1763,9 +1797,9 @@ ShellFindFilePathEx (
     return (NULL);\r
   }\r
   for (ExtensionWalker = FileExtension, TempChar2 = (CHAR16*)FileExtension;  TempChar2 != NULL ; ExtensionWalker = TempChar2 + 1){\r
-    StrCpy(TestPath, FileName);\r
+    StrnCpy(TestPath, FileName, Size/sizeof(CHAR16) - 1);\r
     if (ExtensionWalker != NULL) {\r
-      StrCat(TestPath, ExtensionWalker);\r
+      StrnCat(TestPath, ExtensionWalker, Size/sizeof(CHAR16) - 1 - StrLen(TestPath));\r
     }\r
     TempChar = StrStr(TestPath, L";");\r
     if (TempChar != NULL) {\r
@@ -1869,6 +1903,7 @@ InternalIsOnCheckList (
 \r
   @param[in] Name               pointer to Name of parameter found\r
   @param[in] AlwaysAllowNumbers TRUE to allow numbers, FALSE to not.\r
+  @param[in] TimeNumbers        TRUE to allow numbers with ":", FALSE otherwise.\r
 \r
   @retval TRUE                  the Parameter is a flag.\r
   @retval FALSE                 the Parameter not a flag.\r
@@ -1877,7 +1912,8 @@ BOOLEAN
 EFIAPI\r
 InternalIsFlag (\r
   IN CONST CHAR16               *Name,\r
-  IN BOOLEAN                    AlwaysAllowNumbers\r
+  IN CONST BOOLEAN              AlwaysAllowNumbers,\r
+  IN CONST BOOLEAN              TimeNumbers\r
   )\r
 {\r
   //\r
@@ -1888,7 +1924,7 @@ InternalIsFlag (
   //\r
   // If we accept numbers then dont return TRUE. (they will be values)\r
   //\r
-  if (((Name[0] == L'-' || Name[0] == L'+') && ShellIsHexaDecimalDigitCharacter(Name[1])) && AlwaysAllowNumbers) {\r
+  if (((Name[0] == L'-' || Name[0] == L'+') && InternalShellIsHexOrDecimalNumber(Name+1, FALSE, FALSE, TimeNumbers)) && AlwaysAllowNumbers) {\r
     return (FALSE);\r
   }\r
 \r
@@ -1948,6 +1984,7 @@ InternalCommandLineParse (
   UINTN                         ValueSize;\r
   UINTN                         Count;\r
   CONST CHAR16                  *TempPointer;\r
+  UINTN                         CurrentValueSize;\r
 \r
   CurrentItemPackage = NULL;\r
   GetItemValue = 0;\r
@@ -2003,13 +2040,12 @@ InternalCommandLineParse (
         *CheckPackage = NULL;\r
         return (EFI_OUT_OF_RESOURCES);\r
       }\r
-      CurrentItemPackage->Name  = AllocateZeroPool(StrSize(Argv[LoopCounter]));\r
+      CurrentItemPackage->Name  = AllocateCopyPool(StrSize(Argv[LoopCounter]), Argv[LoopCounter]);\r
       if (CurrentItemPackage->Name == NULL) {\r
         ShellCommandLineFreeVarList(*CheckPackage);\r
         *CheckPackage = NULL;\r
         return (EFI_OUT_OF_RESOURCES);\r
       }\r
-      StrCpy(CurrentItemPackage->Name,  Argv[LoopCounter]);\r
       CurrentItemPackage->Type  = CurrentItemType;\r
       CurrentItemPackage->OriginalPosition = (UINTN)(-1);\r
       CurrentItemPackage->Value = NULL;\r
@@ -2022,6 +2058,7 @@ InternalCommandLineParse (
         // possibly trigger the next loop(s) to populate the value of this item\r
         //\r
         case TypeValue:\r
+        case TypeTimeValue:\r
           GetItemValue = 1;\r
           ValueSize = 0;\r
           break;\r
@@ -2041,36 +2078,37 @@ InternalCommandLineParse (
           ASSERT(GetItemValue == 0);\r
           break;\r
       }\r
-    } else if (GetItemValue != 0 && !InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers)) {\r
-      ASSERT(CurrentItemPackage != NULL);\r
+    } else if (GetItemValue != 0 && CurrentItemPackage != NULL && !InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, (CONST BOOLEAN)(CurrentItemPackage->Type == TypeTimeValue))) {\r
       //\r
       // get the item VALUE for a previous flag\r
       //\r
       if (StrStr(Argv[LoopCounter], L" ") == NULL) {\r
-        CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);\r
+        CurrentValueSize = ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
+        CurrentItemPackage->Value = ReallocatePool(ValueSize, CurrentValueSize, CurrentItemPackage->Value);\r
         ASSERT(CurrentItemPackage->Value != NULL);\r
         if (ValueSize == 0) {\r
-          StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+          StrnCpy(CurrentItemPackage->Value, Argv[LoopCounter], CurrentValueSize/sizeof(CHAR16) - 1);\r
         } else {\r
-          StrCat(CurrentItemPackage->Value, L" ");\r
-          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+          StrnCat(CurrentItemPackage->Value, L" ", CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
+          StrnCat(CurrentItemPackage->Value, Argv[LoopCounter], CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
         }\r
         ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
       } else {\r
         //\r
         // the parameter has spaces.  must be quoted.\r
         //\r
-        CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16) + sizeof(CHAR16) + sizeof(CHAR16), CurrentItemPackage->Value);\r
+        CurrentValueSize =  ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16) + sizeof(CHAR16) + sizeof(CHAR16);\r
+        CurrentItemPackage->Value = ReallocatePool(ValueSize, CurrentValueSize, CurrentItemPackage->Value);\r
         ASSERT(CurrentItemPackage->Value != NULL);\r
         if (ValueSize == 0) {\r
-          StrCpy(CurrentItemPackage->Value, L"\"");\r
-          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
-          StrCat(CurrentItemPackage->Value, L"\"");\r
+          StrnCpy(CurrentItemPackage->Value, L"\"", CurrentValueSize/sizeof(CHAR16) - 1);\r
+          StrnCat(CurrentItemPackage->Value, Argv[LoopCounter], CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
+          StrnCat(CurrentItemPackage->Value, L"\"", CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
         } else {\r
-          StrCat(CurrentItemPackage->Value, L" ");\r
-          StrCat(CurrentItemPackage->Value, L"\"");\r
-          StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
-          StrCat(CurrentItemPackage->Value, L"\"");\r
+          StrnCat(CurrentItemPackage->Value, L" ", CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
+          StrnCat(CurrentItemPackage->Value, L"\"", CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
+          StrnCat(CurrentItemPackage->Value, Argv[LoopCounter], CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
+          StrnCat(CurrentItemPackage->Value, L"\"", CurrentValueSize/sizeof(CHAR16) - 1 - StrLen(CurrentItemPackage->Value));\r
        }\r
         ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
       }\r
@@ -2078,7 +2116,7 @@ InternalCommandLineParse (
       if (GetItemValue == 0) {\r
         InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
       }\r
-    } else if (!InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers) ){ //|| ProblemParam == NULL) {\r
+    } else if (!InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers, FALSE)){\r
       //\r
       // add this one as a non-flag\r
       //\r
@@ -2098,13 +2136,12 @@ InternalCommandLineParse (
       }\r
       CurrentItemPackage->Name  = NULL;\r
       CurrentItemPackage->Type  = TypePosition;\r
-      CurrentItemPackage->Value = AllocateZeroPool(StrSize(TempPointer));\r
+      CurrentItemPackage->Value = AllocateCopyPool(StrSize(TempPointer), TempPointer);\r
       if (CurrentItemPackage->Value == NULL) {\r
         ShellCommandLineFreeVarList(*CheckPackage);\r
         *CheckPackage = NULL;\r
         return (EFI_OUT_OF_RESOURCES);\r
       }\r
-      StrCpy(CurrentItemPackage->Value, TempPointer);\r
       CurrentItemPackage->OriginalPosition = Count++;\r
       InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
     } else {\r
@@ -2112,10 +2149,7 @@ InternalCommandLineParse (
       // this was a non-recognised flag... error!\r
       //\r
       if (ProblemParam != NULL) {\r
-        *ProblemParam = AllocateZeroPool(StrSize(Argv[LoopCounter]));\r
-        if (*ProblemParam != NULL) {\r
-          StrCpy(*ProblemParam, Argv[LoopCounter]);\r
-        }\r
+        *ProblemParam = AllocateCopyPool(StrSize(Argv[LoopCounter]), Argv[LoopCounter]);\r
       }\r
       ShellCommandLineFreeVarList(*CheckPackage);\r
       *CheckPackage = NULL;\r
@@ -2582,7 +2616,7 @@ ShellCopySearchAndReplace(
   if (Replace == NULL) {\r
     return (EFI_OUT_OF_RESOURCES);\r
   }\r
-  NewString = SetMem16(NewString, NewSize, CHAR_NULL);\r
+  NewString = ZeroMem(NewString, NewSize);\r
   while (*SourceString != CHAR_NULL) {\r
     //\r
     // if we find the FindTarget and either Skip == FALSE or Skip  and we\r
@@ -2597,7 +2631,7 @@ ShellCopySearchAndReplace(
         FreePool(Replace);\r
         return (EFI_BUFFER_TOO_SMALL);\r
       }\r
-      StrCat(NewString, Replace);\r
+      StrnCat(NewString, Replace, NewSize/sizeof(CHAR16) - 1 - StrLen(NewString));\r
     } else {\r
       Size = StrSize(NewString);\r
       if (Size + sizeof(CHAR16) > NewSize) {\r
@@ -3102,7 +3136,7 @@ ShellStrToUintn(
 \r
   Hex = FALSE;\r
 \r
-  if (!InternalShellIsHexOrDecimalNumber(String, Hex, TRUE)) {\r
+  if (!InternalShellIsHexOrDecimalNumber(String, Hex, TRUE, FALSE)) {\r
     Hex = TRUE;\r
   }\r
 \r
@@ -3279,7 +3313,9 @@ ShellPromptForResponse (
       //\r
       gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
       Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-      ASSERT_EFI_ERROR(Status);\r
+      if (EFI_ERROR(Status)) {\r
+        break;\r
+      }\r
       ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
       if (Key.UnicodeChar == L'Q' || Key.UnicodeChar ==L'q') {\r
         *Resp = ShellPromptResponseQuit;\r
@@ -3296,9 +3332,15 @@ ShellPromptForResponse (
       //\r
       *Resp = ShellPromptResponseMax;\r
       while (*Resp == ShellPromptResponseMax) {\r
+        if (ShellGetExecutionBreakFlag()) {\r
+          Status = EFI_ABORTED;\r
+          break;\r
+        }\r
         gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
         Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-        ASSERT_EFI_ERROR(Status);\r
+        if (EFI_ERROR(Status)) {\r
+          break;\r
+        }\r
         ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
         switch (Key.UnicodeChar) {\r
           case L'Y':\r
@@ -3324,9 +3366,15 @@ ShellPromptForResponse (
       //\r
       *Resp = ShellPromptResponseMax;\r
       while (*Resp == ShellPromptResponseMax) {\r
+        if (ShellGetExecutionBreakFlag()) {\r
+          Status = EFI_ABORTED;\r
+          break;\r
+        }\r
         gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
         Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-        ASSERT_EFI_ERROR(Status);\r
+        if (EFI_ERROR(Status)) {\r
+          break;\r
+        }\r
         ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
         switch (Key.UnicodeChar) {\r
           case L'Y':\r
@@ -3358,10 +3406,16 @@ ShellPromptForResponse (
       //\r
       *Resp = ShellPromptResponseMax;\r
       while (*Resp == ShellPromptResponseMax) {\r
+        if (ShellGetExecutionBreakFlag()) {\r
+          Status = EFI_ABORTED;\r
+          break;\r
+        }\r
         gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
         if (Type == ShellPromptResponseTypeEnterContinue) {\r
           Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-          ASSERT_EFI_ERROR(Status);\r
+          if (EFI_ERROR(Status)) {\r
+            break;\r
+          }\r
           ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
           if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
             *Resp = ShellPromptResponseContinue;\r
@@ -3385,9 +3439,15 @@ ShellPromptForResponse (
       //\r
       *Resp = ShellPromptResponseMax;\r
       while (*Resp == ShellPromptResponseMax) {\r
+        if (ShellGetExecutionBreakFlag()) {\r
+          Status = EFI_ABORTED;\r
+          break;\r
+        }\r
         gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
         Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-        ASSERT_EFI_ERROR(Status);\r
+        if (EFI_ERROR(Status)) {\r
+          break;\r
+        }\r
         ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
         switch (Key.UnicodeChar) {\r
           case L'Y':\r
@@ -3406,9 +3466,15 @@ ShellPromptForResponse (
         ShellPrintEx(-1, -1, L"%s", Prompt);\r
       }\r
       while(1) {\r
+        if (ShellGetExecutionBreakFlag()) {\r
+          Status = EFI_ABORTED;\r
+          break;\r
+        }\r
         gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
         Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-        ASSERT_EFI_ERROR(Status);\r
+        if (EFI_ERROR(Status)) {\r
+          break;\r
+        }\r
         ShellPrintEx(-1, -1, L"%c", Key.UnicodeChar);\r
         if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
           break;\r
@@ -3419,6 +3485,7 @@ ShellPromptForResponse (
       break;\r
     //\r
     // This is the location to add new prompt types.\r
+    // If your new type loops remember to add ExecutionBreak support.\r
     //\r
     default:\r
       ASSERT(FALSE);\r
@@ -3486,6 +3553,7 @@ ShellPromptForResponseHii (
   @param[in] String       The string to evaluate.\r
   @param[in] ForceHex     TRUE - always assume hex.\r
   @param[in] StopAtSpace  TRUE to halt upon finding a space, FALSE to keep going.\r
+  @param[in] TimeNumbers        TRUE to allow numbers with ":", FALSE otherwise.\r
 \r
   @retval TRUE        It is all numeric (dec/hex) characters.\r
   @retval FALSE       There is a non-numeric character.\r
@@ -3495,7 +3563,8 @@ EFIAPI
 InternalShellIsHexOrDecimalNumber (\r
   IN CONST CHAR16   *String,\r
   IN CONST BOOLEAN  ForceHex,\r
-  IN CONST BOOLEAN  StopAtSpace\r
+  IN CONST BOOLEAN  StopAtSpace,\r
+  IN CONST BOOLEAN  TimeNumbers\r
   )\r
 {\r
   BOOLEAN Hex;\r
@@ -3539,6 +3608,9 @@ InternalShellIsHexOrDecimalNumber (
   // loop through the remaining characters and use the lib function\r
   //\r
   for ( ; String != NULL && *String != CHAR_NULL && !(StopAtSpace && *String == L' ') ; String++){\r
+    if (TimeNumbers && (String[0] == L':')) {\r
+      continue;\r
+    }\r
     if (Hex) {\r
       if (!ShellIsHexaDecimalDigitCharacter(*String)) {\r
         return (FALSE);\r
@@ -3862,10 +3934,10 @@ ShellConvertStringToUint64(
 \r
   Hex = ForceHex;\r
 \r
-  if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace)) {\r
+  if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {\r
     if (!Hex) {\r
       Hex = TRUE;\r
-      if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace)) {\r
+      if (!InternalShellIsHexOrDecimalNumber(String, Hex, StopAtSpace, FALSE)) {\r
         return (EFI_INVALID_PARAMETER);\r
       }\r
     } else {\r
@@ -3881,7 +3953,7 @@ ShellConvertStringToUint64(
   //\r
   // make sure we have something left that is numeric.\r
   //\r
-  if (Walker == NULL || *Walker == CHAR_NULL || !InternalShellIsHexOrDecimalNumber(Walker, Hex, StopAtSpace)) {\r
+  if (Walker == NULL || *Walker == CHAR_NULL || !InternalShellIsHexOrDecimalNumber(Walker, Hex, StopAtSpace, FALSE)) {\r
     return (EFI_INVALID_PARAMETER);\r
   }\r
 \r
@@ -4190,3 +4262,41 @@ ShellDeleteFileByName(
   return(Status);\r
   \r
 }\r
+\r
+/**\r
+  Cleans off all the quotes in the string.\r
+\r
+  @param[in]     OriginalString   pointer to the string to be cleaned.\r
+  @param[out]   CleanString      The new string with all quotes removed. \r
+                                                  Memory allocated in the function and free \r
+                                                  by caller.\r
+\r
+  @retval EFI_SUCCESS   The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalShellStripQuotes (\r
+  IN  CONST CHAR16     *OriginalString,\r
+  OUT CHAR16           **CleanString\r
+  )\r
+{\r
+  CHAR16            *Walker;\r
+  \r
+  if (OriginalString == NULL || CleanString == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  *CleanString = AllocateCopyPool (StrSize (OriginalString), OriginalString);\r
+  if (*CleanString == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  for (Walker = *CleanString; Walker != NULL && *Walker != CHAR_NULL ; Walker++) {\r
+    if (*Walker == L'\"') {\r
+      CopyMem(Walker, Walker+1, StrSize(Walker) - sizeof(Walker[0]));\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r