diff options
author | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-03-29 19:31:18 +0000 |
---|---|---|
committer | jcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-03-29 19:31:18 +0000 |
commit | 980d554e3ab6457a4f7a455fabcc297d6e93547f (patch) | |
tree | 3e7e650a2a805f1900116fe0a06438119010fc4d /ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c | |
parent | 64d753f12d74b683b52862b7a4403fa2cd56a171 (diff) | |
download | edk2-platforms-980d554e3ab6457a4f7a455fabcc297d6e93547f.tar.xz |
smbiosview - add user input verification.
HexEdit/Edit
- More user input verification for HexEdit.
- updated title bar refreshment.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11448 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c index 511eb9e636..0a97a6ca29 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c @@ -44,7 +44,7 @@ ShellCommandRunHexEdit ( SHELL_STATUS ShellStatus;
LIST_ENTRY *Package;
CONST CHAR16 *Cwd;
- CHAR16 *NFS;
+ CHAR16 *NewName;
CHAR16 *Spot;
CONST CHAR16 *Name;
UINTN Offset;
@@ -54,7 +54,7 @@ ShellCommandRunHexEdit ( Buffer = NULL;
ShellStatus = SHELL_SUCCESS;
- NFS = NULL;
+ NewName = NULL;
Cwd = NULL;
Buffer = NULL;
Name = NULL;
@@ -90,10 +90,7 @@ ShellCommandRunHexEdit ( // Check for -d
//
if (ShellCommandLineGetFlag(Package, L"-d")){
- if (ShellCommandLineGetCount(Package) < 4) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
- ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetCount(Package) > 4) {
+ if (ShellCommandLineGetCount(Package) > 4) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
@@ -138,7 +135,24 @@ ShellCommandRunHexEdit ( Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
}
}
- ShellCommandLineFreeVarList (Package);
+ if (WhatToDo == FileTypeNone && ShellCommandLineGetRawValue(Package, 1) != NULL) {
+ Name = ShellCommandLineGetRawValue(Package, 1);
+ if (!IsValidFileName(Name)) {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name);
+ ShellStatus = SHELL_INVALID_PARAMETER;
+ } else {
+ WhatToDo = FileTypeFileBuffer;
+ }
+ } else if (WhatToDo == FileTypeNone) {
+ if (gEfiShellProtocol->GetCurDir(NULL) == NULL) {
+ ShellStatus = SHELL_NOT_FOUND;
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellDebug1HiiHandle);
+ } else {
+ NewName = EditGetDefaultFileName(L"bin");
+ Name = NewName;
+ WhatToDo = FileTypeFileBuffer;
+ }
+ }
if (ShellStatus == SHELL_SUCCESS && WhatToDo == FileTypeNone) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
@@ -240,8 +254,10 @@ ShellCommandRunHexEdit ( }
}
}
+ ShellCommandLineFreeVarList (Package);
}
SHELL_FREE_NON_NULL (Buffer);
+ SHELL_FREE_NON_NULL (NewName);
return ShellStatus;
}
|