From d3912eb99e88fa1d797e06881fc6589eae831859 Mon Sep 17 00:00:00 2001 From: Zhichao Gao Date: Mon, 18 Feb 2019 16:28:09 +0800 Subject: [PATCH 1/1] 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 --- ShellPkg/Application/Shell/Shell.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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++; -- 2.39.2