From: Zhichao Gao Date: Mon, 18 Feb 2019 08:28:09 +0000 (+0800) Subject: ShellPkg: add array index check for shell delay option X-Git-Tag: edk2-stable201903~64 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d3912eb99e88fa1d797e06881fc6589eae831859 ShellPkg: add array index check for shell delay option BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1528 Shell delay option without parameters do not check the index of shell parameter argv. Add index check to avoid invalid pointer references. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zhichao Gao Cc: Liming Gao Cc: Ray Ni Reviewed-by: Jaben Carsey Reviewed-by: Liming Gao --- diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index 104f4c8961..ec344137d3 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1,7 +1,7 @@ /** @file This is THE shell (application) - Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
Copyright 2015-2018 Dell Technologies.
This program and the accompanying materials @@ -1002,7 +1002,11 @@ ProcessCommandLine( ) == 0) { ShellInfoObject.ShellInitSettings.BitUnion.Bits.Delay = TRUE; // Check for optional delay value following "-delay" - DelayValueStr = gEfiShellParametersProtocol->Argv[LoopVar + 1]; + if ((LoopVar + 1) >= gEfiShellParametersProtocol->Argc) { + DelayValueStr = NULL; + } else { + DelayValueStr = gEfiShellParametersProtocol->Argv[LoopVar + 1]; + } if (DelayValueStr != NULL){ if (*DelayValueStr == L':') { DelayValueStr++;