audk/SecurityPkg
Laszlo Ersek a7632e913c SecurityPkg/DxeImageVerificationLib: assign WinCertificate after size check
Currently the (SecDataDirLeft <= sizeof (WIN_CERTIFICATE)) check only
guards the de-referencing of the "WinCertificate" pointer. It does not
guard the calculation of the pointer itself:

  WinCertificate = (WIN_CERTIFICATE *) (mImageBase + OffSet);

This is wrong; if we don't know for sure that we have enough room for a
WIN_CERTIFICATE, then even creating such a pointer, not just
de-referencing it, may invoke undefined behavior.

Move the pointer calculation after the size check.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Wenyi Xie <xiewenyi2@huawei.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2215
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200901091221.20948-3-lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Min M Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2020-09-02 10:16:18 +00:00
..
FvReportPei SecurityPkg: Fix spelling errors 2019-10-23 10:23:23 -07:00
Hash2DxeCrypto SecurityPkg/Hash2DxeCrypto: Fix few typos 2020-02-10 22:30:07 +00:00
HddPassword SecurityPkg/HddPassword: Use BaseLib linked list iteration macros 2020-04-21 02:20:51 +00:00
Include SecurityPkg/Tcg2: handle PRE HASH and LOG ONLY 2020-08-26 15:56:11 +00:00
Library SecurityPkg/DxeImageVerificationLib: assign WinCertificate after size check 2020-09-02 10:16:18 +00:00
Pkcs7Verify/Pkcs7VerifyDxe SecurityPkg: Fix few typos 2020-02-10 22:30:07 +00:00
RandomNumberGenerator/RngDxe SecurityPkg: Fix few typos 2020-02-10 22:30:07 +00:00
Tcg SecurityPkg: Initailize variable Status before it is consumed. 2020-09-01 16:11:24 +00:00
VariableAuthenticated/SecureBootConfigDxe SecurityPkg/VariableAuthenticated: Fix few typos 2020-02-10 22:30:07 +00:00
SecurityPkg.ci.yaml SecurityPkg/SecurityPkg.ci.yaml: Add configuration for Ecc check 2020-08-17 03:28:09 +00:00
SecurityPkg.dec SecurityPkg/dsc: add FvEventLogRecordLib 2020-08-26 15:56:11 +00:00
SecurityPkg.dsc SecurityPkg/dsc: add FvEventLogRecordLib 2020-08-26 15:56:11 +00:00
SecurityPkg.uni SecurityPkg: Fix spelling errors 2019-10-23 10:23:23 -07:00
SecurityPkgExtra.uni SecurityPkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:23 -07:00