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.web10.4115.1601424950205740244 for ; Tue, 29 Sep 2020 17:15:50 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: nathaniel.l.desimone@intel.com) IronPort-SDR: aGrHRyKUKdVRKK88f5dHYMNYbGsTyuAq28i1NKnnAPyIHccDxYGNTky9uIeiZYQVPeHoMtQrnL X2gTJrhtgzWQ== X-IronPort-AV: E=McAfee;i="6000,8403,9759"; a="159708753" X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="159708753" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:48 -0700 IronPort-SDR: hxtTwumQOzt3wSvGLYjBAgFnWKIbhX/eoiB3wpjGXm2kr+BJWkOyK/Q86NsGpiE9rfO/R8ZXut HxB2syAdxi2g== X-IronPort-AV: E=Sophos;i="5.77,320,1596524400"; d="scan'208";a="312397975" Received: from nldesimo-desk1.amr.corp.intel.com ([10.209.9.28]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 17:15:43 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Liming Gao , Eric Dong Subject: [edk2-platforms] [PATCH V1 1/2] MinPlatformPkg: Add missing bounds checks to CompressLib Date: Tue, 29 Sep 2020 17:15:28 -0700 Message-Id: <20200930001529.2212-2-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> References: <20200930001529.2212-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Current code only as bounds checks in ASSERT macros. They are also needed in release mode where ASSERT is not used. Signed-off-by: Nate DeSimone Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong --- .../MinPlatformPkg/Library/CompressLib/CompressLib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c index 9f93e1ee2d..537eb3b693 100644 --- a/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/CompressLib/CompressLib.c @@ -1002,7 +1002,10 @@ CountTFreq ( mTFreq[2]++; } } else { - ASSERT((LoopVar3+2)<(2 * NT - 1)); + ASSERT ((LoopVar3 + 2) < (2 * NT - 1)); + if ((LoopVar3 + 2) >= (2 * NT - 1)) { + return; + } mTFreq[LoopVar3 + 2]++; } } @@ -1101,7 +1104,10 @@ WriteCLen ( PutBits (CBIT, Count - 20); } } else { - ASSERT((LoopVar3+2)= NPT) { + return; + } PutBits (mPTLen[LoopVar3 + 2], mPTCode[LoopVar3 + 2]); } } -- 2.27.0.windows.1