From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 218D91A1E3E for ; Thu, 29 Sep 2016 21:31:17 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP; 29 Sep 2016 21:31:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,418,1473145200"; d="scan'208";a="174826452" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 29 Sep 2016 21:31:16 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Liming Gao Date: Fri, 30 Sep 2016 12:31:13 +0800 Message-Id: <20160930043113.541636-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [PATCH] MdeModulePkg/HiiDataBase: Fix NULL deference bug in HiiGetImageInfo X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2016 04:31:17 -0000 The return value of GetImageIdOrAddress() could be NULL if the ImageId is invalid. The patch fixes the bug to return EFI_NOT_FOUND when GetImageIdOrAddress() returns NULL. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Liming Gao --- MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c index 1e3f3bd..33dbc7d 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ImageEx.c @@ -361,6 +361,10 @@ HiiGetImageInfo ( // Find the image block specified by ImageId // CurrentImageBlock = GetImageIdOrAddress (ImagePackage->ImageBlock, &ImageId); + if (CurrentImageBlock == NULL) { + return EFI_NOT_FOUND; + } + switch (CurrentImageBlock->BlockType) { case EFI_HII_IIBT_IMAGE_JPEG: case EFI_HII_IIBT_IMAGE_PNG: -- 2.9.0.windows.1