summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorJaben Carsey <jaben.carsey@intel.com>2013-11-15 18:39:26 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-15 18:39:26 +0000
commit6813ba402a7c52e80cc7aa4eb2a454a6b90ae011 (patch)
tree2891d5861b327341bc62b324751b380015e9a4e1 /ShellPkg
parent4d0da5fb769cb38a215daa1e42d46400c59f9711 (diff)
ShellPkg: verify that leading and trailing % are removed from variable names when doing command line redirection to an environment variable.
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://svn.code.sf.net/p/edk2/code/trunk/edk2@14849 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/ShellParametersProtocol.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 3564e0666..b6598c0cf 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -539,6 +539,35 @@ FixFileName (
}
/**
+ Fix a string to only have the environment variable name, removing starting at the first space of whatever is quoted and removing the leading and trailing %.
+
+ @param[in] FileName The filename to start with.
+
+ @retval NULL FileName was invalid.
+ @return The modified FileName.
+**/
+CHAR16*
+EFIAPI
+FixVarName (
+ IN CHAR16 *FileName
+ )
+{
+ CHAR16 *Copy;
+ CHAR16 *TempLocation;
+
+ Copy = FileName;
+
+ if (FileName[0] == L'%') {
+ Copy = FileName+1;
+ if ((TempLocation = StrStr(Copy , L"%")) != NULL) {
+ TempLocation[0] = CHAR_NULL;
+ }
+ }
+
+ return (FixFileName(Copy));
+}
+
+/**
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
user.
@@ -914,17 +943,17 @@ UpdateStdInStdOutStdErr(
}
}
if (StdErrVarName != NULL) {
- if ((StdErrVarName = FixFileName(StdErrVarName)) == NULL) {
+ if ((StdErrVarName = FixVarName(StdErrVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
if (StdOutVarName != NULL) {
- if ((StdOutVarName = FixFileName(StdOutVarName)) == NULL) {
+ if ((StdOutVarName = FixVarName(StdOutVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}
if (StdInVarName != NULL) {
- if ((StdInVarName = FixFileName(StdInVarName)) == NULL) {
+ if ((StdInVarName = FixVarName(StdInVarName)) == NULL) {
Status = EFI_INVALID_PARAMETER;
}
}