summaryrefslogtreecommitdiff
path: root/ShellPkg
diff options
context:
space:
mode:
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-01 22:16:01 +0000
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-01 22:16:01 +0000
commitae724571beb0cff6edefe42942b7cdc7aa81ee94 (patch)
treeaebe447e031e49a703e77503dec70dcaf46bed30 /ShellPkg
parent5f2915f59380777728344bbbca587d4944f19ed0 (diff)
downloadedk2-platforms-ae724571beb0cff6edefe42942b7cdc7aa81ee94.tar.xz
Comment's added and fixed.
Pointer's checked for NULL before access and after memory allocations. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11499 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Application/Shell/FileHandleWrappers.c2
-rw-r--r--ShellPkg/Application/Shell/ShellParametersProtocol.c8
-rw-r--r--ShellPkg/Include/Library/ShellLib.h2
-rw-r--r--ShellPkg/Include/ShellBase.h2
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c6
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c12
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c7
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c738
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h7
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c3
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c4
-rw-r--r--ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c4
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/For.c108
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c8
-rw-r--r--ShellPkg/Library/UefiShellLevel1CommandsLib/If.c60
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c2
-rw-r--r--ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c15
-rw-r--r--ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c7
19 files changed, 481 insertions, 518 deletions
diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/Application/Shell/FileHandleWrappers.c
index 38fdb8d848..b2163bebb9 100644
--- a/ShellPkg/Application/Shell/FileHandleWrappers.c
+++ b/ShellPkg/Application/Shell/FileHandleWrappers.c
@@ -1547,7 +1547,7 @@ FileInterfaceFileGetInfo(
/**
Set information about a file
- @param File Protocol instance pointer.
+ @param This Protocol instance pointer.
@param InformationType Type of information in Buffer.
@param BufferSize Size of buffer.
@param Buffer The data to write.
diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c
index 76935333d6..238ccd9681 100644
--- a/ShellPkg/Application/Shell/ShellParametersProtocol.c
+++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c
@@ -415,6 +415,14 @@ CleanUpShellParametersProtocol (
return (Status);
}
+/**
+ Determin if a file name represents a unicode file.
+
+ @param[in] FileName Pointer to the filename to open.
+
+ @retval EFI_SUCCESS The file is a unicode file.
+ @return An error upon failure.
+**/
EFI_STATUS
EFIAPI
IsUnicodeFile(
diff --git a/ShellPkg/Include/Library/ShellLib.h b/ShellPkg/Include/Library/ShellLib.h
index 6061262221..12cae5afeb 100644
--- a/ShellPkg/Include/Library/ShellLib.h
+++ b/ShellPkg/Include/Library/ShellLib.h
@@ -1191,7 +1191,7 @@ ShellPromptForResponse (
to prevent invalid answers to question.
@param[in] HiiFormatStringId The format string Id for getting from Hii.
@param[in] HiiFormatHandle The format string Handle for getting from Hii.
- @param[out] Response The pointer to Response, which will be populated upon return.
+ @param[in,out] Response The pointer to Response, which will be populated upon return.
@retval EFI_SUCCESS The operation was sucessful.
@return other The operation failed.
diff --git a/ShellPkg/Include/ShellBase.h b/ShellPkg/Include/ShellBase.h
index bd0462c59c..73ef064207 100644
--- a/ShellPkg/Include/ShellBase.h
+++ b/ShellPkg/Include/ShellBase.h
@@ -15,7 +15,7 @@
#ifndef __SHELL_BASE__
#define __SHELL_BASE__
-#define ABS(a) (a<0)?(-(a)):(a)
+#define ABS(a) ((a<0)?(-(a)):(a))
typedef VOID *SHELL_FILE_HANDLE;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
index afe3ec0858..01321d1ed6 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Compress.c
@@ -237,8 +237,7 @@ FreeMemory (
}
/**
- Initialize String Info Log data structures
-
+ Initialize String Info Log data structures.
**/
VOID
EFIAPI
@@ -1043,8 +1042,7 @@ WritePTLen (
}
/**
- Outputs the code length array for Char&Length Set
-
+ Outputs the code length array for Char&Length Set.
**/
VOID
EFIAPI
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
index fcd0de5cb5..8223847924 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
@@ -357,7 +357,7 @@ FileBufferRestoreMousePosition (
CurrentLine = FileBuffer.CurrentLine;
Line = MoveLine (FRow - FileBuffer.FilePosition.Row);
- if (FColumn > Line->Size) {
+ if (Line == NULL || FColumn > Line->Size) {
HasCharacter = FALSE;
}
@@ -1367,7 +1367,7 @@ GetNewLine (
Change a Unicode string to an ASCII string.
@param[in] UStr The Unicode string.
- @param[in] Lenght The maximum size of AStr.
+ @param[in] Length The maximum size of AStr.
@param[out] AStr ASCII string to pass out.
@return The actuall length.
@@ -1375,9 +1375,9 @@ GetNewLine (
UINTN
EFIAPI
UnicodeToAscii (
- IN CONST CHAR16 *UStr,
- IN CONST UINTN Length,
- OUT CHAR8 *AStr
+ IN CONST CHAR16 *UStr,
+ IN CONST UINTN Length,
+ OUT CHAR8 *AStr
)
{
UINTN Index;
@@ -1621,7 +1621,7 @@ FileBufferSave (
//
// now everything is ready , you can set the new file name to filebuffer
//
- if (StrCmp (FileName, FileBuffer.FileName) != 0) {
+ if (FileName != NULL && FileBuffer.FileName != NULL && StrCmp (FileName, FileBuffer.FileName) != 0) {
//
// not the same
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
index a82fdb9bb8..713332ea0d 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
@@ -91,7 +91,7 @@ MainCommandSearch (
VOID
);
-/*
+/**
search string in file buffer, and replace it with another str
@retval EFI_SUCCESS The operation was successful.
@@ -589,8 +589,8 @@ MainCommandSearch (
return EFI_SUCCESS;
}
-/*
- search string in file buffer, and replace it with another str
+/**
+ Search string in file buffer, and replace it with another str.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@@ -1589,7 +1589,6 @@ GetTextY (
@retval EFI_SUCCESS The operation was successful.
@retval EFI_NOT_FOUND There was no mouse support found.
**/
-STATIC
EFI_STATUS
EFIAPI
MainEditorHandleMouseInput (
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
index 675850cff4..8aa75b419a 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c
@@ -78,22 +78,19 @@ EFI_STATUS
HBufferImageInit (
VOID
)
-/*++
-
-Routine Description:
-
+/**
Initialization function for HBufferImage
-Arguments:
+
None
-Returns:
+
EFI_SUCCESS
EFI_LOAD_ERROR
---*/
+**/
{
EFI_STATUS Status;
@@ -151,24 +148,21 @@ EFI_STATUS
HBufferImageBackup (
VOID
)
-/*++
-
-Routine Description:
-
+/**
Backup function for HBufferImage
Only a few fields need to be backup.
This is for making the file buffer refresh
as few as possible.
-Arguments:
+
None
-Returns:
+
EFI_SUCCESS
---*/
+**/
{
HBufferImageBackupVar.MousePosition = HBufferImage.MousePosition;
@@ -207,10 +201,7 @@ EFI_STATUS
HBufferImageFreeLines (
VOID
)
-/*++
-
-Routine Description:
-
+/**
Free all the lines in HBufferImage
Fields affected:
Lines
@@ -218,15 +209,15 @@ Routine Description:
NumLines
ListHead
-Arguments:
+
None
-Returns:
+
EFI_SUCCESS
---*/
+**/
{
HFreeLines (HBufferImage.ListHead, HBufferImage.Lines);
@@ -241,21 +232,18 @@ EFI_STATUS
HBufferImageCleanup (
VOID
)
-/*++
-
-Routine Description:
-
+/**
Cleanup function for HBufferImage
-Arguments:
+
None
-Returns:
+
EFI_SUCCESS
---*/
+**/
{
EFI_STATUS Status;
@@ -284,13 +272,10 @@ HBufferImagePrintLine (
IN HEFI_EDITOR_COLOR_UNION New
)
-/*++
-
-Routine Description:
-
+/**
Print Line on Row
-Arguments:
+
Line - Line to print
Row - Row on screen ( begin from 1 )
@@ -298,11 +283,11 @@ Arguments:
Orig - Orig
New - Light display
-Returns:
+
EFI_SUCCESS
---*/
+**/
{
UINTN Index;
@@ -691,7 +676,7 @@ HBufferImageRestoreMousePosition (
CurrentLine = HBufferImage.CurrentLine;
Line = HMoveLine (FRow - HBufferImage.BufferPosition.Row);
- if (FColumn > Line->Size) {
+ if (Line == NULL || FColumn > Line->Size) {
HasCharacter = FALSE;
}
@@ -738,21 +723,18 @@ EFI_STATUS
HBufferImageRestorePosition (
VOID
)
-/*++
-
-Routine Description:
-
+/**
Set cursor position according to HBufferImage.DisplayPosition.
-Arguments:
+
None
-Returns:
+
EFI_SUCCESS
---*/
+**/
{
//
// set cursor position
@@ -766,26 +748,17 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Refresh function for HBufferImage.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_LOAD_ERROR A Load error occured.
+
+**/
EFI_STATUS
HBufferImageRefresh (
VOID
)
-/*++
-
-Routine Description:
-
- Refresh function for HBufferImage
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
- EFI_LOAD_ERROR
-
---*/
{
LIST_ENTRY *Link;
HEFI_EDITOR_LINE *Line;
@@ -811,8 +784,8 @@ Returns:
// no definite required refresh
// and file position displayed on screen has not been changed
//
- if (HBufferImageNeedRefresh == FALSE &&
- HBufferImageOnlyLineNeedRefresh == FALSE &&
+ if (!HBufferImageNeedRefresh &&
+ !HBufferImageOnlyLineNeedRefresh &&
HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow
) {
HBufferImageRestoreMousePosition ();
@@ -826,7 +799,7 @@ Returns:
//
// only need to refresh current line
//
- if (HBufferImageOnlyLineNeedRefresh == TRUE && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {
+ if (HBufferImageOnlyLineNeedRefresh && HBufferImageBackupVar.LowVisibleRow == HBufferImage.LowVisibleRow) {
HBufferImagePrintLine (
HBufferImage.CurrentLine,
@@ -935,7 +908,22 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Read an image into a buffer friom a source.
+
+ @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
+ @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] MemoryOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
+ @param[in] MemorySize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
+ @param[in] BufferType The type of buffer to save. IGNORED.
+ @param[in] Recover TRUE for recovermode, FALSE otherwise.
+
+ @return EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
+EFIAPI
HBufferImageRead (
IN CONST CHAR16 *FileName,
IN CONST CHAR16 *DiskName,
@@ -985,6 +973,19 @@ HBufferImageRead (
return Status;
}
+/**
+ Save the current image.
+
+ @param[in] FileName Pointer to the file name. OPTIONAL and ignored if not FileTypeFileBuffer.
+ @param[in] DiskName Pointer to the disk name. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] DiskOffset Offset into the disk. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] DiskSize Size of the disk buffer. OPTIONAL and ignored if not FileTypeDiskBuffer.
+ @param[in] MemoryOffset Offset into the Memory. OPTIONAL and ignored if not FileTypeMemBuffer.
+ @param[in] MemorySize Size of the Memory buffer. OPTIONAL and ignored if not FileTypeMemBuffer.
+ @param[in] BufferType The type of buffer to save. IGNORED.
+
+ @return EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageSave (
IN CHAR16 *FileName,
@@ -1035,29 +1036,20 @@ HBufferImageSave (
return Status;
}
-HEFI_EDITOR_LINE *
-HBufferImageCreateLine (
- VOID
- )
-/*++
-
-Routine Description:
-
- Create a new line and append it to the line list
+/**
+ Create a new line and append it to the line list.
Fields affected:
NumLines
Lines
-Arguments:
+ @retval NULL create line failed.
+ @return the line created.
- None
-
-Returns:
-
- NULL -- create line failed
- Not NULL -- the line created
-
---*/
+**/
+HEFI_EDITOR_LINE *
+HBufferImageCreateLine (
+ VOID
+ )
{
HEFI_EDITOR_LINE *Line;
@@ -1091,26 +1083,15 @@ Returns:
return Line;
}
+/**
+ Free the current image.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageFree (
VOID
)
-/*++
-
-Routine Description:
-
- Function called when load a new file in. It will free all the old lines
- and set FileModified field to FALSE
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
//
// free all lines
@@ -1120,33 +1101,25 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Dispatch input to different handler
+
+ @param[in] Key The input key:
+ the keys can be:
+ ASCII KEY
+ Backspace/Delete
+ Direction key: up/down/left/right/pgup/pgdn
+ Home/End
+ INS
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_LOAD_ERROR A load error occured.
+ @retval EFI_OUT_OF_RESOURCES A Memory allocation failed.
+**/
EFI_STATUS
HBufferImageHandleInput (
IN EFI_INPUT_KEY *Key
)
-/*++
-
-Routine Description:
-
- Dispatch input to different handler
-
-Arguments:
-
- Key -- input key
- the keys can be:
- ASCII KEY
- Backspace/Delete
- Direction key: up/down/left/right/pgup/pgdn
- Home/End
- INS
-
-Returns:
-
- EFI_SUCCESS
- EFI_LOAD_ERROR
- EFI_OUT_OF_RESOURCES
-
---*/
{
EFI_STATUS Status;
@@ -1231,27 +1204,20 @@ Returns:
return Status;
}
+/**
+ ASCII key + Backspace + return.
+
+ @param[in] Char The input char.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_LOAD_ERROR A load error occured.
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
+**/
EFI_STATUS
+EFIAPI
HBufferImageDoCharInput (
IN CHAR16 Char
)
-/*++
-
-Routine Description:
-
- ASCII key + Backspace + return
-
-Arguments:
-
- Char -- input char
-
-Returns:
-
- EFI_SUCCESS
- EFI_LOAD_ERROR
- EFI_OUT_OF_RESOURCES
-
---*/
{
EFI_STATUS Status;
@@ -1289,26 +1255,19 @@ Returns:
return Status;
}
+/**
+ change char to int value based on Hex.
+
+ @param[in] Char The input char.
+
+ @return The character's index value.
+ @retval -1 The operation failed.
+**/
INTN
+EFIAPI
HBufferImageCharToHex (
IN CHAR16 Char
)
-/*++
-
-Routine Description:
-
- change char to int value based on Hex
-
-Arguments:
-
- Char -- input char
-
-Returns:
-
- int value;
-
-
---*/
{
//
// change the character to hex
@@ -1328,26 +1287,19 @@ Returns:
return -1;
}
+/**
+ Add character.
+
+ @param[in] Char -- input char.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
+**/
EFI_STATUS
+EFIAPI
HBufferImageAddChar (
IN CHAR16 Char
)
-/*++
-
-Routine Description:
-
- Add character
-
-Arguments:
-
- Char -- input char
-
-Returns:
-
- EFI_SUCCESS
- EFI_OUT_OF_RESOURCES
-
---*/
{
HEFI_EDITOR_LINE *Line;
HEFI_EDITOR_LINE *NewLine;
@@ -1403,7 +1355,7 @@ Returns:
// at the low 4 bits of the last character of a full line
// so if no next line, need to create a new line
//
- if (High == FALSE && FCol == 0x10) {
+ if (!High && FCol == 0x10) {
HBufferImageOnlyLineNeedRefresh = FALSE;
HBufferImageNeedRefresh = TRUE;
@@ -1431,7 +1383,7 @@ Returns:
//
// if already at end of this line, scroll it to the start of next line
//
- if (FCol == 0x10 && High == FALSE) {
+ if (FCol == 0x10 && !High) {
//
// definitely has next line
//
@@ -1469,27 +1421,18 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Check user specified FileRow and FileCol is in current screen.
+
+ @param[in] FileRow Row of file position ( start from 1 ).
+
+ @retval TRUE It's on the current screen.
+ @retval FALSE It's not on the current screen.
+**/
BOOLEAN
HInCurrentScreen (
IN UINTN FileRow
)
-/*++
-
-Routine Description:
-
- Check user specified FileRow and FileCol is in current screen
-
-Arguments:
-
- FileRow -- Row of file position ( start from 1 )
-
-
-Returns:
-
- TRUE
- FALSE
-
---*/
{
if (FileRow >= HBufferImage.LowVisibleRow && FileRow <= HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 5) - 1) {
return TRUE;
@@ -1498,26 +1441,19 @@ Returns:
return FALSE;
}
+/**
+ Check user specified FileRow is above current screen.
+
+ @param[in] FileRow Row of file position ( start from 1 ).
+
+ @retval TRUE It is above the current screen.
+ @retval FALSE It is not above the current screen.
+
+**/
BOOLEAN
HAboveCurrentScreen (
IN UINTN FileRow
)
-/*++
-
-Routine Description:
-
- Check user specified FileRow is above current screen
-
-Arguments:
-
- FileRow -- Row of file position ( start from 1 )
-
-Returns:
-
- TRUE
- FALSE
-
---*/
{
if (FileRow < HBufferImage.LowVisibleRow) {
return TRUE;
@@ -1526,26 +1462,19 @@ Returns:
return FALSE;
}
+/**
+ Check user specified FileRow is under current screen.
+
+ @param[in] FileRow Row of file position ( start from 1 ).
+
+ @retval TRUE It is under the current screen.
+ @retval FALSE It is not under the current screen.
+
+**/
BOOLEAN
HUnderCurrentScreen (
IN UINTN FileRow
)
-/*++
-
-Routine Description:
-
- Check user specified FileRow is under current screen
-
-Arguments:
-
- FileRow -- Row of file position ( start from 1 )
-
-Returns:
-
- TRUE
- FALSE
-
---*/
{
if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 5) - 1) {
return TRUE;
@@ -1554,29 +1483,20 @@ Returns:
return FALSE;
}
+/**
+ According to cursor's file position, adjust screen display.
+
+ @param[in] NewFilePosRow Row of file position ( start from 1 ).
+ @param[in] NewFilePosCol Column of file position ( start from 1 ).
+ @param[in] HighBits Cursor will on high4 bits or low4 bits.
+**/
VOID
HBufferImageMovePosition (
IN UINTN NewFilePosRow,
IN UINTN NewFilePosCol,
IN BOOLEAN HighBits
)
-/*++
-
-Routine Description:
-
- According to cursor's file position, adjust screen display
-Arguments:
-
- NewFilePosRow -- Row of file position ( start from 1 )
- NewFilePosCol -- Column of file position ( start from 1 )
- HighBits -- cursor will on high4 bits or low4 bits
-
-Returns:
-
- None
-
---*/
{
INTN RowGap;
UINTN Abs;
@@ -1641,7 +1561,7 @@ Returns:
NewDisplayCol++;
}
- if (HighBits == FALSE) {
+ if (!HighBits) {
NewDisplayCol++;
}
@@ -1654,25 +1574,15 @@ Returns:
}
+/**
+ Scroll cursor to right.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageScrollRight (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to right
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -1722,25 +1632,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to left.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageScrollLeft (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to left
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
@@ -1781,25 +1681,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to the next line
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageScrollDown (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to the next line
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -1836,25 +1726,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to previous line
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageScrollUp (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to previous line
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -1880,25 +1760,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to next page
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImagePageDown (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to next page
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -1943,25 +1813,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to previous page
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImagePageUp (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to previous page
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -2001,25 +1861,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to start of line
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageHome (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to start of line
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -2043,25 +1893,15 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Scroll cursor to end of line.
+
+ @retval EFI_SUCCESS Teh operation was successful.
+**/
EFI_STATUS
HBufferImageEnd (
VOID
)
-/*++
-
-Routine Description:
-
- Scroll cursor to end of line
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
UINTN FRow;
@@ -2092,6 +1932,11 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Get the size of the open buffer.
+
+ @retval The size in bytes.
+**/
UINTN
HBufferImageGetTotalSize (
VOID
@@ -2122,28 +1967,21 @@ HBufferImageGetTotalSize (
return Size;
}
+/**
+ Delete character from buffer.
+
+ @param[in] Pos Position, Pos starting from 0.
+ @param[in] Count The Count of characters to delete.
+ @param[OUT] DeleteBuffer The DeleteBuffer.
+
+ @retval EFI_SUCCESS Success
+**/
EFI_STATUS
HBufferImageDeleteCharacterFromBuffer (
IN UINTN Pos,
IN UINTN Count,
OUT UINT8 *DeleteBuffer
)
-/*++
-Routine Description:
-
- Delete character from buffer
-
-Arguments:
-
- Pos - Position, Pos starting from 0
- Count - Count
- DeleteBuffer - DeleteBuffer
-
-Returns:
-
- EFI_SUCCESS Success
-
---*/
{
UINTN Index;
@@ -2264,28 +2102,21 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Add character to buffer, add before pos.
+
+ @param[in] Pos Position, Pos starting from 0.
+ @param[in] Count Count of characters to add.
+ @param[in] AddBuffer Add buffer.
+
+ @retval EFI_SUCCESS Success.
+**/
EFI_STATUS
HBufferImageAddCharacterToBuffer (
IN UINTN Pos,
IN UINTN Count,
IN UINT8 *AddBuffer
)
-/*++'
-Routine Description:
-
- Add character to buffer, add before pos
-
-Arguments:
-
- Pos - Position, Pos starting from 0
- Count - Count
- AddBuffer - Add buffer
-
-Returns:
-
- EFI_SUCCESS Success
-
---*/
{
INTN Index;
@@ -2378,25 +2209,16 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Delete the previous character.
+
+ @retval EFI_SUCCESS The operationw as successful.
+**/
EFI_STATUS
+EFIAPI
HBufferImageDoBackspace (
VOID
)
-/*++
-
-Routine Description:
-
- delete the previous character
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
@@ -2447,25 +2269,16 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Delete current character from line.
+
+ @retval EFI_SUCCESS The operationw as successful.
+**/
EFI_STATUS
+EFIAPI
HBufferImageDoDelete (
VOID
)
-/*++
-
-Routine Description:
-
- Delete current character from line
-
-Arguments:
-
- None
-
-Returns:
-
- EFI_SUCCESS
-
---*/
{
HEFI_EDITOR_LINE *Line;
@@ -2513,30 +2326,40 @@ Returns:
return EFI_SUCCESS;
}
+/**
+ Change the raw buffer to a list of lines for the UI.
+
+ @param[in] Buffer The pointer to the buffer to fill.
+ @param[in] Bytes The size of the buffer in bytes.
+
+ @retval EFI_SUCCESS The operation was successful.
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
+**/
EFI_STATUS
+EFIAPI
HBufferImageBufferToList (
IN VOID *Buffer,
IN UINTN Bytes
)
{
- UINTN i;
- UINTN j;
+ UINTN TempI;
+ UINTN TempJ;
UINTN Left;
HEFI_EDITOR_LINE *Line;
UINT8 *BufferPtr;
- i = 0;
+ TempI = 0;
Left = 0;
BufferPtr = (UINT8 *) Buffer;
//
// parse file content line by line
//
- while (i < Bytes) {
- if (Bytes - i >= 0x10) {
+ while (TempI < Bytes) {
+ if (Bytes - TempI >= 0x10) {
Left = 0x10;
} else {
- Left = Bytes - i;
+ Left = Bytes - TempI;
}
//
@@ -2549,9 +2372,9 @@ HBufferImageBufferToList (
Line->Size = Left;
- for (j = 0; j < Left; j++) {
- Line->Buffer[j] = BufferPtr[i];
- i++;
+ for (TempJ = 0; TempJ < Left; TempJ++) {
+ Line->Buffer[TempJ] = BufferPtr[TempI];
+ TempI++;
}
}
@@ -2569,7 +2392,16 @@ HBufferImageBufferToList (
return EFI_SUCCESS;
}
+/**
+ Change the list of lines from the UI to a raw buffer.
+
+ @param[in] Buffer The pointer to the buffer to fill.
+ @param[in] Bytes The size of the buffer in bytes.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
+EFIAPI
HBufferImageListToBuffer (
IN VOID *Buffer,
IN UINTN Bytes
@@ -2599,6 +2431,7 @@ HBufferImageListToBuffer (
Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);
+ //@todo shouldn't this be an error???
if (Count + Line->Size > Bytes) {
return EFI_SUCCESS;
}
@@ -2616,14 +2449,21 @@ HBufferImageListToBuffer (
return EFI_SUCCESS;
}
+/**
+ Move the mouse in the image buffer.
+
+ @param[in] TextX The x-coordinate.
+ @param[in] TextY The y-coordinate.
+**/
VOID
+EFIAPI
HBufferImageAdjustMousePosition (
IN INT32 TextX,
IN INT32 TextY
)
{
- UINTN X;
- UINTN Y;
+ UINTN TempX;
+ UINTN TempY;
UINTN AbsX;
UINTN AbsY;
@@ -2632,7 +2472,7 @@ HBufferImageAdjustMousePosition (
// This function will change it to MousePosition
//
//
- // get absolute X value
+ // get absolute TempX value
//
if (TextX >= 0) {
AbsX = TextX;
@@ -2640,7 +2480,7 @@ HBufferImageAdjustMousePosition (
AbsX = -TextX;
}
//
- // get absolute Y value
+ // get absolute TempY value
//
if (TextY >= 0) {
AbsY = TextY;
@@ -2648,48 +2488,48 @@ HBufferImageAdjustMousePosition (
AbsY = -TextY;
}
- X = HBufferImage.MousePosition.Column;
- Y = HBufferImage.MousePosition.Row;
+ TempX = HBufferImage.MousePosition.Column;
+ TempY = HBufferImage.MousePosition.Row;
if (TextX >= 0) {
- X += TextX;
+ TempX += TextX;
} else {
- if (X >= AbsX) {
- X -= AbsX;
+ if (TempX >= AbsX) {
+ TempX -= AbsX;
} else {
- X = 0;
+ TempX = 0;
}
}
if (TextY >= 0) {
- Y += TextY;
+ TempY += TextY;
} else {
- if (Y >= AbsY) {
- Y -= AbsY;
+ if (TempY >= AbsY) {
+ TempY -= AbsY;
} else {
- Y = 0;
+ TempY = 0;
}
}
//
// check whether new mouse column position is beyond screen
// if not, adjust it
//
- if (X >= 10 && X <= (10 + 0x10 * 3 - 1)) {
- HBufferImage.MousePosition.Column = X;
- } else if (X < 10) {
+ if (TempX >= 10 && TempX <= (10 + 0x10 * 3 - 1)) {
+ HBufferImage.MousePosition.Column = TempX;
+ } else if (TempX < 10) {
HBufferImage.MousePosition.Column = 10;
- } else if (X > (10 + 0x10 * 3 - 1)) {
+ } else if (TempX > (10 + 0x10 * 3 - 1)) {
HBufferImage.MousePosition.Column = 10 + 0x10 * 3 - 1;
}
//
// check whether new mouse row position is beyond screen
// if not, adjust it
//
- if (Y >= 2 && Y <= (HMainEditor.ScreenSize.Row - 4)) {
- HBufferImage.MousePosition.Row = Y;
- } else if (Y < 2) {
+ if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 4)) {
+ HBufferImage.MousePosition.Row = TempY;
+ } else if (TempY < 2) {
HBufferImage.MousePosition.Row = 2;
- } else if (Y > (HMainEditor.ScreenSize.Row - 4)) {
+ } else if (TempY > (HMainEditor.ScreenSize.Row - 4)) {
HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 4);
}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
index d661e50524..5e637ce700 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.h
@@ -188,10 +188,15 @@ HBufferImageReplace (
UINTN
);
+/**
+ Free the current image.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
EFI_STATUS
HBufferImageFree (
VOID
- ) ;
+ );
EFI_STATUS
HBufferImageDeleteCharacterFromBuffer (
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
index fd6387a20a..5397071b3b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c
@@ -489,7 +489,8 @@ Returns:
//
// now everything is ready , you can set the new file name to filebuffer
//
- if (BufferTypeBackup != FileTypeFileBuffer || StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0) {
+ if ((BufferTypeBackup != FileTypeFileBuffer && FileName != NULL) ||
+ (FileName != NULL && HFileImage.FileName != NULL && StringNoCaseCompare (&FileName, &HFileImage.FileName) != 0)){
//
// not the same
//
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
index 53718c7751..36c913939b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexEdit.c
@@ -135,8 +135,8 @@ ShellCommandRunHexEdit (
Size = ShellStrToUintn(ShellCommandLineGetRawValue(Package, 2));
}
}
- if (WhatToDo == FileTypeNone && ShellCommandLineGetRawValue(Package, 1) != NULL) {
- Name = ShellCommandLineGetRawValue(Package, 1);
+ Name = ShellCommandLineGetRawValue(Package, 1);
+ if (WhatToDo == FileTypeNone && Name != NULL) {
if (!IsValidFileName(Name)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, Name);
ShellStatus = SHELL_INVALID_PARAMETER;
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
index 961e0cca68..58c25f81d4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c
@@ -1868,9 +1868,9 @@ Returns:
|| ReadChange ) {
MainTitleBarRefresh (
- HMainEditor.BufferImage->BufferType == FileTypeFileBuffer?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer?HMainEditor.BufferImage->DiskImage->Name:NULL,
+ HMainEditor.BufferImage->BufferType == FileTypeFileBuffer&&HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->FileName:HMainEditor.BufferImage->BufferType == FileTypeDiskBuffer&&HMainEditor.BufferImage->DiskImage!=NULL?HMainEditor.BufferImage->DiskImage->Name:NULL,
HMainEditor.BufferImage->BufferType,
- HMainEditor.BufferImage->FileImage->ReadOnly,
+ (BOOLEAN)(HMainEditor.BufferImage->FileImage!=NULL?HMainEditor.BufferImage->FileImage->ReadOnly:FALSE),
HMainEditor.BufferImage->Modified,
HMainEditor.ScreenSize.Column,
HMainEditor.ScreenSize.Row,
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index 7b7e5928bd..f3e3f5f37b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -2969,7 +2969,7 @@ QueryTable (
//
if (High > Low && Key >= Low && Key <= High) {
StrnCpy (Info, Table[Index].Info, InfoLen-1);
- StrCat (Info, L"\n");
+ StrnCat (Info, L"\n", InfoLen - StrLen(Info));
return Key;
}
//
@@ -2977,7 +2977,7 @@ QueryTable (
//
if (Table[Index].Key == Key) {
StrnCpy (Info, Table[Index].Info, InfoLen-1);
- StrCat (Info, L"\n");
+ StrnCat (Info, L"\n", InfoLen - StrLen(Info));
return Key;
}
}
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
index ddcfd45de3..64110099d3 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c
@@ -69,6 +69,7 @@ ShellCommandRunEndFor (
{
EFI_STATUS Status;
BOOLEAN Found;
+ SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
@@ -86,6 +87,7 @@ ShellCommandRunEndFor (
Found = MoveToTag(GetPreviousNode, L"for", L"endfor", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE);
if (!Found) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx(
-1,
-1,
@@ -94,9 +96,9 @@ ShellCommandRunEndFor (
gShellLevel1HiiHandle,
L"For",
L"EndFor",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_NOT_FOUND);
}
return (SHELL_SUCCESS);
@@ -421,7 +423,16 @@ ShellCommandRunFor (
Info->CurrentValue = NULL;
ArgSetWalker = ArgSet;
if (ArgSetWalker[0] != L'(') {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempSpot = StrStr(ArgSetWalker, L")");
@@ -437,7 +448,15 @@ ShellCommandRunFor (
}
}
if (TempSpot == NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
*TempSpot = CHAR_NULL;
@@ -446,7 +465,16 @@ ShellCommandRunFor (
ArgSetWalker++;
}
if (!ShellIsValidForNumber(ArgSetWalker)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
@@ -459,7 +487,16 @@ ShellCommandRunFor (
ArgSetWalker++;
}
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ArgSetWalker[0] == L'-') {
@@ -479,7 +516,16 @@ ShellCommandRunFor (
}
if (ArgSetWalker != NULL && *ArgSetWalker != CHAR_NULL) {
if (ArgSetWalker == NULL || *ArgSetWalker == CHAR_NULL || !ShellIsValidForNumber(ArgSetWalker)){
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (*ArgSetWalker == L')') {
@@ -492,7 +538,16 @@ ShellCommandRunFor (
}
if (StrStr(ArgSetWalker, L" ") != NULL) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
@@ -512,7 +567,16 @@ ShellCommandRunFor (
}
CurrentScriptFile->CurrentCommand->Data = Info;
} else {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT), gShellLevel1HiiHandle, ArgSet, ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_PROBLEM_SCRIPT),
+ gShellLevel1HiiHandle,
+ ArgSet,
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
}
} else {
@@ -553,7 +617,17 @@ ShellCommandRunFor (
// find the matching endfor (we're done with the loop)
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndFor",
+ L"For",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR;
}
if (Info->RemoveSubstAlias) {
@@ -611,7 +685,17 @@ ShellCommandRunFor (
// find the matching endfor (we're done with the loop)
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", NULL, CurrentScriptFile, TRUE, FALSE, FALSE)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"EndFor", L"For", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"EndFor",
+ L"For",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_DEVICE_ERROR;
}
if (Info->RemoveSubstAlias) {
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
index 3e5a59c575..4d48c7f1e9 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/Goto.c
@@ -33,6 +33,7 @@ ShellCommandRunGoto (
SHELL_STATUS ShellStatus;
CHAR16 *CompareString;
UINTN Size;
+ SCRIPT_FILE *CurrentScriptFile;
ShellStatus = SHELL_SUCCESS;
CompareString = NULL;
@@ -79,6 +80,7 @@ ShellCommandRunGoto (
// Check forwards and then backwards for a label...
//
if (!MoveToTag(GetNextNode, L"endfor", L"for", CompareString, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, TRUE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
ShellPrintHiiEx(
-1,
-1,
@@ -87,9 +89,9 @@ ShellCommandRunGoto (
gShellLevel1HiiHandle,
CompareString,
L"Goto",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_NOT_FOUND;
}
FreePool(CompareString);
diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
index a3c4482bb3..1d83f8a246 100644
--- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
+++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c
@@ -825,7 +825,7 @@ ShellCommandRunIf (
BOOLEAN CurrentValue;
END_TAG_TYPE Ending;
END_TAG_TYPE PreviousEnding;
-
+ SCRIPT_FILE *CurrentScriptFile;
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
@@ -843,7 +843,8 @@ ShellCommandRunIf (
//
// Make sure that an End exists.
//
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), TRUE, TRUE, FALSE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, TRUE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -852,9 +853,9 @@ ShellCommandRunIf (
gShellLevel1HiiHandle,
L"EnfIf",
L"If",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -928,7 +929,18 @@ ShellCommandRunIf (
// build up the next statement for analysis
//
if (!BuildNextStatement(CurrentParameter, &EndParameter, &Ending)) {
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SYNTAX_NO_MATCHING), gShellLevel1HiiHandle, L"Then", L"If", ShellCommandGetCurrentScriptFile()->CurrentCommand->Line);
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ ShellPrintHiiEx(
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_SYNTAX_NO_MATCHING),
+ gShellLevel1HiiHandle,
+ L"Then",
+ L"If",
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
//
@@ -979,6 +991,7 @@ ShellCommandRunElse (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) {
@@ -991,8 +1004,9 @@ ShellCommandRunElse (
return (SHELL_UNSUPPORTED);
}
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1001,12 +1015,12 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"If",
L"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
- if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ if (!MoveToTag(GetPreviousNode, L"if", L"else", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1015,13 +1029,13 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"If",
L"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
- if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, ShellCommandGetCurrentScriptFile(), FALSE, FALSE, FALSE)) {
+ if (!MoveToTag(GetNextNode, L"endif", L"if", NULL, CurrentScriptFile, FALSE, FALSE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1030,9 +1044,9 @@ ShellCommandRunElse (
gShellLevel1HiiHandle,
L"EndIf",
"Else",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
@@ -1052,6 +1066,7 @@ ShellCommandRunEndIf (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ SCRIPT_FILE *CurrentScriptFile;
ASSERT_EFI_ERROR(CommandInit());
if (gEfiShellParametersProtocol->Argc > 1) {
@@ -1064,7 +1079,8 @@ ShellCommandRunEndIf (
return (SHELL_UNSUPPORTED);
}
- if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, ShellCommandGetCurrentScriptFile(), FALSE, TRUE, FALSE)) {
+ CurrentScriptFile = ShellCommandGetCurrentScriptFile();
+ if (!MoveToTag(GetPreviousNode, L"if", L"endif", NULL, CurrentScriptFile, FALSE, TRUE, FALSE)) {
ShellPrintHiiEx(
-1,
-1,
@@ -1073,9 +1089,9 @@ ShellCommandRunEndIf (
gShellLevel1HiiHandle,
L"If",
L"EndIf",
- ShellCommandGetCurrentScriptFile()!=NULL
- &&ShellCommandGetCurrentScriptFile()->CurrentCommand!=NULL
- ?ShellCommandGetCurrentScriptFile()->CurrentCommand->Line:0);
+ CurrentScriptFile!=NULL
+ && CurrentScriptFile->CurrentCommand!=NULL
+ ? CurrentScriptFile->CurrentCommand->Line:0);
return (SHELL_DEVICE_ERROR);
}
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
index e7d19c9bed..68130d4db8 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Map.c
@@ -650,7 +650,7 @@ PerformMappingDisplay(
&BufferSize,
HandleBuffer);
}
- if (!EFI_ERROR(Status)) {
+ if (!EFI_ERROR(Status) && HandleBuffer != NULL) {
//
// Get the map name(s) for each one.
//
diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
index 53b7770dfe..51cf33f1ba 100644
--- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
+++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c
@@ -30,7 +30,7 @@ EFIAPI
HandleVol(
IN CONST CHAR16 *Path,
IN CONST BOOLEAN Delete,
- IN CONST CHAR16 *Name
+ IN CONST CHAR16 *Name OPTIONAL
)
{
EFI_STATUS Status;
@@ -45,6 +45,7 @@ HandleVol(
ShellStatus = SHELL_SUCCESS;
if (
+ Name != NULL && (
StrStr(Name, L"%") != NULL ||
StrStr(Name, L"^") != NULL ||
StrStr(Name, L"*") != NULL ||
@@ -60,7 +61,7 @@ HandleVol(
StrStr(Name, L">") != NULL ||
StrStr(Name, L"?") != NULL ||
StrStr(Name, L"/") != NULL ||
- StrStr(Name, L" ") != NULL
+ StrStr(Name, L" ") != NULL )
){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, Name);
return (SHELL_INVALID_PARAMETER);
@@ -150,6 +151,8 @@ HandleVol(
}
gEfiShellProtocol->CloseFile(ShellFileHandle);
+
+ ASSERT(SysInfo != NULL);
//
// print VolumeInfo table
@@ -200,6 +203,7 @@ ShellCommandRunVol (
CHAR16 *FullPath;
CHAR16 *TempSpot;
UINTN Length;
+ CONST CHAR16 *NewName;
Length = 0;
ProblemParam = NULL;
@@ -266,20 +270,21 @@ ShellCommandRunVol (
StrnCatGrow(&FullPath, &Length, PathName, 0);
StrnCatGrow(&FullPath, &Length, L":\\", 0);
DeleteMode = ShellCommandLineGetFlag(Package, L"-d");
+ NewName = ShellCommandLineGetValue(Package, L"-n");
if (DeleteMode && ShellCommandLineGetFlag(Package, L"-n")) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CON), gShellLevel2HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetFlag(Package, L"-n") && ShellCommandLineGetValue(Package, L"-n") == NULL) {
+ } else if (ShellCommandLineGetFlag(Package, L"-n") && NewName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellLevel2HiiHandle, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
- } else if (ShellCommandLineGetValue(Package, L"-n") != NULL && StrLen(ShellCommandLineGetValue(Package, L"-n")) > 11) {
+ } else if (NewName != NULL && StrLen(NewName) > 11) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellLevel2HiiHandle, L"-n");
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellStatus == SHELL_SUCCESS) {
ShellStatus = HandleVol(
FullPath,
DeleteMode,
- ShellCommandLineGetValue(Package, L"-n")
+ NewName
);
}
}
diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
index 3bfdf847de..d4326448f6 100644
--- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
+++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ifconfig.c
@@ -781,9 +781,14 @@ IfconfigSetNicAddrByHii (
if (ConfigHdr != NULL) {
Length = StrLen (ConfigHdr);
} else {
- Length = 0;
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ goto ON_EXIT;
}
ConfigResp = AllocateZeroPool ((Length + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
+ if (ConfigResp == NULL) {
+ ShellStatus = SHELL_OUT_OF_RESOURCES;
+ goto ON_EXIT;
+ }
if (ConfigHdr != NULL) {
StrCpy (ConfigResp, ConfigHdr);
}