ShellPkg/UefiShellNetwork2CommandsLib: Check array index before access

Moves the range check for the index into the array before attempting
any accesses using the array index.

Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
This commit is contained in:
Michael Kubacki 2023-09-06 12:39:21 -04:00 committed by mergify[bot]
parent 60d0f5802b
commit 493a375eef
1 changed files with 1 additions and 1 deletions

View File

@ -382,7 +382,7 @@ IfConfig6PrintIpAddr (
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_IFCONFIG6_INFO_COLON), gShellNetwork2HiiHandle);
while ((Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0) && (Index < PREFIXMAXLEN)) {
while ((Index < PREFIXMAXLEN) && (Ip->Addr[Index] == 0) && (Ip->Addr[Index + 1] == 0)) {
Index = Index + 2;
if (Index > PREFIXMAXLEN - 2) {
break;