summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2012-01-27 18:42:43 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2012-01-27 18:42:43 +0000
commit49bd498dfef23e7c48cc2e55f369587608b9dd34 (patch)
tree2f1911070de2fe6fd4472b62915d81d5bdae1914 /ShellPkg
parente1d996b3912a57faa10bb0879bfb1941e556157e (diff)
downloadedk2-platforms-49bd498dfef23e7c48cc2e55f369587608b9dd34.tar.xz
ShellPkg: parameters with spaces need quotes.
signed-off-by: jcarsey reviewed-by: leegrosenbaum git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12960 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellLib/UefiShellLib.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
index 74f1cd3bac..aabd9140df 100644
--- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c
+++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c
@@ -1,7 +1,7 @@
/** @file
Provides interface to shell functionality for shell commands and applications.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -2015,15 +2015,34 @@ InternalCommandLineParse (
//
// get the item VALUE for a previous flag
//
- CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);
- ASSERT(CurrentItemPackage->Value != NULL);
- if (ValueSize == 0) {
- StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);
+ if (StrStr(Argv[LoopCounter], L" ") == NULL) {
+ CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);
+ ASSERT(CurrentItemPackage->Value != NULL);
+ if (ValueSize == 0) {
+ StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);
+ } else {
+ StrCat(CurrentItemPackage->Value, L" ");
+ StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);
+ }
+ ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
} else {
- StrCat(CurrentItemPackage->Value, L" ");
- StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);
+ //
+ // the parameter has spaces. must be quoted.
+ //
+ CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16) + sizeof(CHAR16) + sizeof(CHAR16), CurrentItemPackage->Value);
+ ASSERT(CurrentItemPackage->Value != NULL);
+ if (ValueSize == 0) {
+ StrCpy(CurrentItemPackage->Value, L"\"");
+ StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);
+ StrCat(CurrentItemPackage->Value, L"\"");
+ } else {
+ StrCat(CurrentItemPackage->Value, L" ");
+ StrCat(CurrentItemPackage->Value, L"\"");
+ StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);
+ StrCat(CurrentItemPackage->Value, L"\"");
+ }
+ ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
}
- ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);
GetItemValue--;
if (GetItemValue == 0) {
InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);
@@ -2587,12 +2606,10 @@ InternalPrintTo (
return (gEfiShellProtocol->WriteFile(gEfiShellParametersProtocol->StdOut, &Size, (VOID*)String));
}
if (mEfiShellInterface != NULL) {
- if (mEfiShellInterface->RedirArgc == 0) {
- //
- // Divide in half for old shell. Must be string length not size.
- //
- Size /=2; // Divide in half only when no redirection.
- }
+ //
+ // Divide in half for old shell. Must be string length not size.
+ //
+ Size /= 2;
return (mEfiShellInterface->StdOut->Write(mEfiShellInterface->StdOut, &Size, (VOID*)String));
}
ASSERT(FALSE);
@@ -3647,10 +3664,10 @@ InternalShellStrHexToUint64 (
String++;
//
- // Skip spaces if requested
+ // stop at spaces if requested
//
- while (StopAtSpace && *String == L' ') {
- String++;
+ if (StopAtSpace && *String == L' ') {
+ break;
}
}