From 493a375eef584be2beaaa3d418a8e7ff333c5468 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Wed, 6 Sep 2023 12:39:21 -0400 Subject: 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 Cc: Michael D Kinney Signed-off-by: Michael Kubacki Reviewed-by: Liming Gao Reviewed-by: Michael D Kinney Reviewed-by: Zhichao Gao --- ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c index 7c80bba465..5cb92c485b 100644 --- a/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c +++ b/ShellPkg/Library/UefiShellNetwork2CommandsLib/Ifconfig6.c @@ -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; -- cgit v1.2.3