From nobody Tue May 7 22:38:42 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 150604541485818.629774956973847; Thu, 21 Sep 2017 18:56:54 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 75C2021ECCB07; Thu, 21 Sep 2017 18:53:46 -0700 (PDT) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 B080E20945B6F for ; Thu, 21 Sep 2017 18:53:44 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2017 18:56:51 -0700 Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 21 Sep 2017 18:56:50 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,426,1500966000"; d="scan'208";a="314895316" From: Dandan Bi To: edk2-devel@lists.01.org Date: Fri, 22 Sep 2017 09:56:42 +0800 Message-Id: <1506045402-318760-1-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [patch] MdeModulePkg/SetupBrowser:Add NULL check before using a pointer 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: , Cc: Hao Wu , Eric Dong MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add NULL pointer check before using a pointer to avoid possible NULL pointer dereference. Cc: Eric Dong Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Hao Wu --- MdeModulePkg/Universal/SetupBrowserDxe/Setup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/= Universal/SetupBrowserDxe/Setup.c index 48beeb6..c2cfa5c 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -1484,11 +1484,13 @@ BufferToValue ( // // Other type of Questions // if (Question->QuestionReferToBitField) { Buffer =3D (UINT8 *)AllocateZeroPool (Question->StorageWidth); - ASSERT (Buffer !=3D NULL); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } Dst =3D Buffer; } else { Dst =3D (UINT8 *) &Question->HiiValue.Value; } } @@ -1546,15 +1548,13 @@ BufferToValue ( } } =20 *StringPtr =3D TempChar; =20 - if (Question->QuestionReferToBitField) { + if (Buffer !=3D NULL && Question->QuestionReferToBitField) { GetBitsQuestionValue (Question, Buffer); - if (Buffer !=3D NULL) { - FreePool (Buffer); - } + FreePool (Buffer); } =20 return Status; } =20 --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel