mirror of https://github.com/acidanthera/audk.git
ShellPkg/UefiShellLevel3CommandsLib: fix string over-read
In the for-loop condition of original code, the expression *CurrentCommand != CHAR_NULL is put before expression CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16) When CurrentCommand walks to the end of string buffer, one more character over the end of string buffer will be read and then stop. To fix this issue, just move the last expression to the first one. Because of short-circuit evaludation of and-expression, the following one *CurrentCommand != CHAR_NULL will not be evaluated if the expression before it is evaludated as FALSE. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
This commit is contained in:
parent
bac7f02365
commit
c3492bd9bb
|
@ -397,7 +397,7 @@ ShellCommandRunHelp (
|
|||
CopyListOfCommandNamesWithDynamic(&SortedCommandList, &SortedCommandListSize);
|
||||
|
||||
for (CurrentCommand = SortedCommandList
|
||||
; CurrentCommand != NULL && *CurrentCommand != CHAR_NULL && CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16)
|
||||
; CurrentCommand != NULL && CurrentCommand < SortedCommandList + SortedCommandListSize/sizeof(CHAR16) && *CurrentCommand != CHAR_NULL
|
||||
; CurrentCommand += StrLen(CurrentCommand) + 1
|
||||
) {
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue