Commit Graph

276 Commits

Author SHA1 Message Date
Michael Kinney e044364b82 ShellPkg/Shell: Add double quotes to args with white space
https://bugzilla.tianocore.org/show_bug.cgi?id=332

When the ShellLib ShellExecute() API or the Shell
Protocol Execute() API are used to execute a
command, the arguments are parsed to produce the
Argc/Argv list in the Shell Parameters Protocol and
double quotes are removed from arguments that are
surrounded by double quotes.  This is the required
behavior of the Shell Parameters Protocol.

The ProcessCommandLine() function in the shell
implementation uses the Argc/Argv list from the
Shell Parameters Protocol to assemble a new command
line, but the double quotes that may have been
originally present for an argument are not preserved.

ProcessCommandLine() is updated to check if an
argument added to the generated command line
contains one or more white space characters, and
if it does, double quotes are added around the
argument.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
2017-01-11 10:34:58 -08:00
Chen A Chen 5016d46603 ShellPkg: Fix a bug ">>v" cannot append data to environment variable
When ">v" is used to redirect the command output to environment
variable, the ending "\r\n\0" is removed before setting to environment
variable but the length is not updated.
It causes ">>v" fails to append data to the environment variable
created by ">v".
The patch fixes the above bug.

Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2017-01-06 20:46:41 +08:00
Chen A Chen c5c994c573 ShellPkg/Application: Fix ">v" cannot update environment variable
When ">v" is used to redirect the command output to environment
variable (e.g.: "echo xxx >v yyy"), we only called SetVariable()
to update the variable storage but forgot to update the cached
environment variables in gShellEnvVarList.
When updating the variable storage, the existing code unnecessary
saved the ending NULL character into variable storage.

The patch fixes all the above issues.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
2016-12-09 09:26:28 +08:00
Bi, Dandan 8009b2e47f ShellPkg: Fix the coding style issue
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2016-11-10 15:58:38 +08:00
Ruiyu Ni 28165f245f ShellPkg: Update sources to include MdePkg protocol definitions
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-10-19 10:26:16 +08:00
Laszlo Ersek 09bd67f095 ShellPkg/Shell: fix CopyGuid() arg order in EfiShellGetGuidFromName()
The destination GUID comes first; from
"MdePkg/Include/Library/BaseMemoryLib.h":

> GUID *
> EFIAPI
> CopyGuid (
>   OUT GUID       *DestinationGuid,
>   IN CONST GUID  *SourceGuid
>   );

Here "NewGuid" is the GUID looked up by GetGuidFromStringName(), and
"Guid" is where EfiShellGetGuidFromName() has to propagate that result to.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Tim Lewis <tim.lewis@insyde.com>
Reported-by: Tim Lewis <tim.lewis@insyde.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Tim Lewis <tim.lewis@insyde.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-10-18 19:30:38 +02:00
Chen A Chen c20bd8e1e2 ShellPkg/Application: Remove unnecessary EFIAPI
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
2016-10-09 10:27:45 +08:00
Cinnamon Shia 8550b5f081 ShellPkg/Shell: Update CRC32 in the EFI System Table header
Update CRC32 in the EFI System Table header after shell changes the
value of gST->ConsoleOutHandle and gST->ConOut

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia <cinnamon.shia@hpe.com>
Reviewed-By: Tapan Shah <tapandshah@hpe.com>
Reviewed-By: Jaben Carsey <Jaben.carsey@intel.com>
2016-10-03 14:36:18 -07:00
Tapan Shah 583448b441 ShellPkg: Expand special output file to include "NULL" and case insensitive
As per ECR 1349 change in UEFI Shell Specification 2.2, expanding
a special output file name to include "NULL". Previously it only
supported "NUL" as a special output file and it was case sensitive.
With this change both "NUL" and "NULL" are special output file and
checked as case insensitive.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-09-22 14:17:24 -07:00
Dandan Bi 00afc8f820 ShellPkg: Fix the incorrect return status in function FindFiles()
According to the latest shell spec, in function FindFiles(),
when no files were found, it should return EFI_NOT_FOUND.
But current codes don't follow the spec.
This patch is to fix this issue.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2016-09-01 16:38:07 +08:00
Ruiyu Ni 1219c85df4 Revert "ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib"
This reverts commit c0bcd3433f.
The above commit causes several regression of "echo" command:
1. Double quotes are not being stripped from the final text. UEFI Shell 2.2 section 3.4.5 chops out the quotes.
2. Output redirection is not working as expected. Text is being redirected, but the ‘> …’ text should not be.
3. Inconsistent special character handling.  For example, comments with # seem to be parsed out correctly, but handing of ^ is incorrect.
In summary, ‘echo “You are ^#1” > t.txt’ results in the below content in t.txt:
 “You are ^#1” > t.txt

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
2016-08-25 13:00:47 +08:00
Ruiyu Ni d25d59cb7e ShellPkg: Fix FindFiles() to handle "fsx:EFI\BOOT" path
When the FilePattern is similar to "fsx:EFI\BOOT", FindFiles()
cannot handle it correctly because it always assumes there is
"\\" after "fsx:".

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
2016-08-10 10:17:08 +08:00
Ruiyu Ni db2e266a0e ShellPkg: TAB logic incorrectly shows files in CWD when typing \<TAB>
It should shows files in root directory of current map.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
2016-08-10 10:17:05 +08:00
Ruiyu Ni 9fcfa150fb ShellPkg: TAB logic incorrectly chops out fs0: when typing fs0:<TAB>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
2016-08-10 10:17:00 +08:00
Ruiyu Ni 031403460c ShellPkg: Unregister hotkey callback when exiting Shell
Commit 9168df3dea
"ShellPkg/ShellProtocol.c: Handle memory allocation failure"
only keeps the protocol clean up in CleanUpShellProtocol() and
creates a new function CleanUpShellEnvironment() which calls
CleanUpShellProtocol(), then unregisters the hotkey callback.

But the commit forgot to change the Shell.c to call
CleanUpShellEnvironment() which causes the hotkey callback is
not unregistered while the callback function doesn't exist
when Shell exits.

This causes system hang when pressing CTRL+C after exiting shell.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2016-07-29 09:52:40 +08:00
Ruiyu Ni 51686a7a29 ShellPkg: Fix a potential NULL pointer deference issue
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2016-07-25 10:20:13 +08:00
Ruiyu Ni c0bcd3433f ShellPkg: Move FindFirstCharacter/GetNextParameter to ShellCommandLib
And add Shell prefix to the two library APIs.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-07-20 10:27:51 +08:00
Ruiyu Ni 9168df3dea ShellPkg/ShellProtocol.c: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-07-18 10:55:05 +08:00
Ruiyu Ni ffbc60a027 ShellPkg/ShellAddEnvVarToList: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-07-18 10:55:02 +08:00
Ruiyu Ni 31e5b912b9 ShellPkg/IsVolatileEnv: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-07-18 10:54:59 +08:00
Ruiyu Ni b2c036a7f0 ShellPkg/Shell.c: Handle memory allocation failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-07-18 10:54:56 +08:00
Marvin H?user bd3fc8133b ShellPkg/App: Fix memory leak and save resources.
1) RunSplitCommand() allocates the initial SplitStdOut via
   CreateFileInterfaceMem(). Free SplitStdIn after the swap to fix
   the memory leak.

2) In RunSplitCommand(), SplitStdOut is checked for equality with
   StdIn. This cannot happen due to the if-check within the swap.
   Hence remove it.

3) UefiMain() doesn't free SplitList. Delete all list entries and
   reinitialize the list when in DEBUG. This does not include the
   CreateFileInterfaceMem()-allocated SplitStd mentioned in 1), so
   keep the ASSERT() until resolved.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
2016-05-25 10:16:46 +08:00
Marvin H?user f3a51e989a ShellPkg: Also accept gEfiUnicodeCollation2ProtocolGuid for parsing.
The EFI_UNICODE_COLLATION_PROTOCOL can have two different GUIDs.
Look for both to support more UEFI implementations.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
2016-05-20 14:16:47 +08:00
Pedroa Liu b8f3601daa ShellPkg: Fix the incorrect behavior when pressing 'shift' key.
If 'ReadKeyStroke' function return EFI_NOT_READY then skip it.
If the return value is EFI_DEVICE_ERROR clean the currentString buffer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Pedroa Liu <pedroa.liu@insyde.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
2016-05-18 09:41:29 +08:00
Jaben Carsey 0822201906 ShellPkg: Use a local variable to cache the pointer.
CC: Qiu Shumin <shumin.qiu@intel.com>
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>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
2016-05-13 08:03:44 -07:00
Jaben Carsey 063aa89bef report line number for command errors in a script.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
2016-05-12 08:15:00 -07:00
Qiu Shumin 91a92220f7 ShellPkg: Fix Shell treats every .EFI file as an executable application.
UEFI Shell 2.x cannot recognize whether a .EFI file is an application or
a driver. This means when we typed in a driver image in Shell command
line, Shell will load the driver image and try to run the entry point
function of the driver.
This patch check the ImageCodeType to fix the issue.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
2016-04-26 14:37:50 +08:00
Qiu Shumin b62bb8854f ShellPkg : Cache the environment variable into memory to enhance
the performance.

Currently UEFI Shell reads variable storage to get the environment
variables every time running a new command. And reading(writing)
UEFI variables is a high cost operation on most platforms. In order
to enhance the performance this patch read the variable storage once
and cache the environment variables in memory. Every further 'set'
command will save the variable not only to Shell cache, but also the
flash variable storage.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by:Ruiyu Ni <ruiyu.ni@intel.com>
2016-04-15 11:10:30 +08:00
Liming Gao 06ac66ecb6 ShellPkg: Update Guid/Protocol usages in INF files.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Shumin Qiu <shumin.qiu@intel.com>
2016-04-13 14:52:59 +08:00
Ard Biesheuvel 481b93f7f0 ShellPkg AARCH64: remove DEBUG BuildOptions override
The BuildOptions for AARCH64 in Application/Shell/Shell.inf only affect
the core Shell binary, and not the Shell component libraries which are
merged into the final Shell binary via NULL library class resolution.

This means we need to override the UEFI_APPLICATION build options in
the platform .DSC anyway, there is no point in setting these options
here as well. So remove them.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2016-03-25 12:37:47 +01:00
Qiu Shumin 19c427a7ce ShellPkg: Remove the unused local variable.
Remove the unused local variable to refine the code.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc:Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2016-03-17 14:35:53 +08:00
Qiu Shumin dcbdb8bfb0 ShellPkg: Per UEFI Shell 2.2 SPEC to make Shell supports 'NoNesting'.
This patch makes Shell support -nonesting invocation option. This option
specifies that EFI_SHELL_PROTOCOL.Execute API nesting of a new Shell
instance is optional and dependent on the 'nonesting' Shell environment
variable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jim Dailey <Jim_Dailey@Dell.com>
2016-03-16 16:09:49 +08:00
Qiu Shumin 9c17810a36 ShellPkg: Fix Shell ASSERT when read 'TAB' key fail from 'ConIn'.
Free 'FoundFileList' when read 'TAB' key fail to avoid memory leak and ASSERT.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2016-03-14 16:24:46 +08:00
Qiu Shumin 231ad7d866 ShellPkg: Use DOS format end of line.
Use DOS format end of line(CR, LF).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-03-09 15:30:59 +08:00
Jim_Dailey@Dell.com c8d9d0e2bd ShellPkg: Increase reallocation size for temp memory files
If data of any real size were to be piped from one command to another,
an inordinate amount of time could be taken up by reallocating memory
that is only 10 bytes bigger than what is currently needed. Also, this
could cause unwelcome memory fragmentation.

Added a define to control how much memory is reallocated beyond that
which is currently needed. Set it to 1K vs. the original 10 bytes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-03-03 12:45:19 +08:00
Jim_Dailey@Dell.com d73fc181e7 ShellPkg: Do not write the UNICODE BOM on ConOut.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-03-03 12:45:18 +08:00
Jim_Dailey@Dell.com 7bcd3ff611 ShellPkg: Add FileSize member to shell memory file structure.
The shell uses the memory file structure to manage temporary files in
memory that support piping of output from one command into the the
input of another command.  The BufferSize member is the size of the
internal buffer, not the size of the data that was written to the
file. So, it was possible to read beyond the EOF of these files as
reads used BufferSize. Now FileSize tracks the actual size of these
files (the number of bytes written, not the number of bytes available
in the buffer), and the reads use this member.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-03-03 12:45:18 +08:00
Jim_Dailey@Dell.com 0b966ddd61 ShellPkg: Don't strip BOM when piping UCS2 data to a UEFI app
If the BOM is stripped from StdIn, then an app that duplicates StdIn
will not be able to duplicate, say, a UCS2 file that was piped into
it (the output file it creates would not start with a BOM).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
Reviewed-by: Jaben Carsey <Jaben.Carsey@intel.com>
2016-03-01 13:37:19 -08:00
Qiu Shumin 8d4eec6d97 ShellPkg: Support finding help message embedded in resource section.
UEFI Shell scandalizes the help message in spec level so that a standalone
UEFI shell application can never get "-?" switch, instead the Shell core
(interpreter) detects the "-?" and finds .MAN file for that shell
application in certain spec defined paths, then show the help extracted
from that .MAN file.

But it means distributing a UEFI shell application not only means
distributing a .EFI file but also distributing a .MAN file. If the text
formatted .MAN file is corrupted (edited by user by mistake), or is
missing (deleted by user by mistake), no help will be shown to user.

So this patch enhance the Shell to make it support finding help message
imbedded in resource section of application image.

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2016-02-24 15:11:14 +08:00
Qiu Shumin 9eec4d38c0 ShellPkg: Do NULL pointer check before the pointer is used.
The pointer 'FileInterface->Buffer' returned from 'AllocateZeroPool' in function
'CreateFileInterfaceMem' may be NULL and will be dereferenced at the following code.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-02-18 14:00:57 +08:00
jaben carsey 9ed21946c7 ShellPkg: Fix ASCII and UNICODE file pipes.
Fix various errors when piping a UNICODE or ASCII file to a simple shell application that reads standard input and writes it to standard output.

1) When the memory file is created by CreateFileInferfaceMem() to capture the pipe output, no UNICODE BOM is written to the memory file. Later, when the memory file is read by the application using ShellFileHandleReadLine(), the function indicates that the file is ASCII because there is no BOM.

2) If the file is piped as ASCII, the ASCII memory image is not correctly created by FileInterfaceMemWrite() as each ASCII character is followed by '\0' in the image (when the ASCII data is written to the memory image, the file position should only be incremented by half the buffer size).

3) ShellFileHandleReadLine() does not read ASCII files correctly (writes to Buffer need to be cast as CHAR8*).

4) FileInterfaceMemRead() and FileInterfaceMemWrite() as somewhat hard to read and difficult to debug with certain tools due to the typecasting of This. Added a local variable (MemFile) of the correct type to these functions and used it instead of This.

Enhancement: ShellFileHandleReadLine() now returns EFI_END_OF_FILE when appropriate.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jim Dailey <jim_dailey@dell.com>
reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2016-02-09 13:22:14 -08:00
Yao Jiewen 4aec9fe30f ShellPkg: Fix memory leak in function 'EfiShellSetCurDir' and 'EfiShellSetMap'.
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yao Jiewen <Jiewen.Yao@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19529 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-25 01:52:56 +00:00
Qiu Shumin 4afbcc112b Subject: [PATCH 5/9] ShellPkg: Fix memory leak in function'ManBufferFindSections'.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Yao Jiewen <Jiewen.Yao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19525 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-25 01:29:38 +00:00
Yao Jiewen a5bc2ff8c9 ShellPkg: Fix memory leak in 'InternalShellExecuteDevicePath'.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yao Jiewen <Jiewen.Yao@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19523 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-24 08:36:45 +00:00
Qiu Shumin 594e780bb9 ShellPkg: Fix the TAB-auto-completion memory leak.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19522 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-24 08:25:52 +00:00
Qiu Shumin 14810d6b64 ShellPkg: Fix memory leak when running Shell script.
When we run following script in Shell:
"
for %a run (1 200)
  echo %a
  memmap
endfor
"
We may find memory leak in system. This patch free buffer in 'BufferToFreeList' to avoid this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19521 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-24 08:14:51 +00:00
Qiu Shumin a4f138a412 ShellPkg: Refine the code logic of 'command history'.
Add the PCD to PcdShellMaxHistoryCommandCount indicate the max count of history commands.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>


git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19520 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-24 08:06:28 +00:00
Qiu Shumin 06e5ae774e ShellPkg: Fix memory leak in ShellProtocol.
1. Close unused file handle.
2. Free the local allocated buffer function returned.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19481 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-23 05:44:19 +00:00
Qiu Shumin 5772d0f540 ShellPkg: Fix memory leak in SimpleTextOutput on file.
Free 'SimpleTextOut->Mode' buffer before 'SimpleTextOut' is free.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19480 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-23 05:36:10 +00:00
Qiu Shumin aa6f7931e4 ShellPkg: Refine the code format.
1. Add function header comment.
2. Non-Boolean comparisons should explicitly use a compare operator.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19424 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-21 05:09:23 +00:00