From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.2806.1571293275521352376 for ; Wed, 16 Oct 2019 23:21:15 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 23:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,306,1566889200"; d="scan'208";a="208164422" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga002.jf.intel.com with ESMTP; 16 Oct 2019 23:21:13 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Dandan Bi , Eric Dong Subject: [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Date: Thu, 17 Oct 2019 14:21:10 +0800 Message-Id: <20191017062111.10568-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 The size of mHiiEfiColors is 16. mHiiEfiColors[Private->Attribute >> 4] may be out of boundary. So add a check for that. Cc: Dandan Bi Cc: Eric Dong Signed-off-by: Shenglei Zhang --- MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c index ca63df168c94..282a7a114d17 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c @@ -999,7 +999,12 @@ GetSystemFont ( } Info->ForegroundColor = mHiiEfiColors[Private->Attribute & 0x0f]; - Info->BackgroundColor = mHiiEfiColors[Private->Attribute >> 4]; + if ((Private->Attribute >> 4) < 16){ + Info->BackgroundColor = mHiiEfiColors[Private->Attribute >> 4]; + } else { + return EFI_INVALID_PARAMETER; + } + Info->FontInfoMask = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE; Info->FontInfo.FontStyle = 0; Info->FontInfo.FontSize = EFI_GLYPH_HEIGHT; -- 2.18.0.windows.1