From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB01E21A18AA9 for ; Mon, 27 Mar 2017 19:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490668023; x=1522204023; h=from:to:cc:subject:date:message-id; bh=49FQmos++uDqfwjkDezCqceav6VMSEbs8NJ9USNdWiM=; b=cPGoNOUC/6S2DaMQ++84/MPY8T0grSD379XIOvyUwMXCVGTuJZwQi6Au U+/uS2BcCD1PSKHTZ60mu4/MvwV4qg==; Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 19:27:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,234,1486454400"; d="scan'208";a="948842264" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 27 Mar 2017 19:27:02 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao A Wu Date: Tue, 28 Mar 2017 10:27:00 +0800 Message-Id: <20170328022700.132784-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] ShellPkg/Shell: Avoid potential null pointer deference X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2017 02:27:04 -0000 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Hao A Wu --- ShellPkg/Application/Shell/Shell.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c index dfcbfb8..af8e523 100644 --- a/ShellPkg/Application/Shell/Shell.c +++ b/ShellPkg/Application/Shell/Shell.c @@ -1162,6 +1162,12 @@ LocateStartupScript ( MapName = ShellInfoObject.NewEfiShellProtocol->GetMapFromDevicePath (&ImageDevicePath); if (MapName != NULL) { StartupScriptPath = StrnCatGrow (&StartupScriptPath, &Size, MapName, 0); + if (StartupScriptPath == NULL) { + // + // Do not locate the startup script in sys path when out of resource. + // + return NULL; + } TempSpot = StrStr (StartupScriptPath, L";"); if (TempSpot != NULL) { *TempSpot = CHAR_NULL; -- 2.9.0.windows.1