From: chenc2 <chen.a.chen@intel.com>
To: edk2-devel@lists.01.org
Cc: chenc2 <chen.a.chen@intel.com>, Wu Hao A <hao.a.wu@intel.com>,
"Cc : Zhang Chao B" <chao.b.zhang@intel.com>
Subject: [PATCH] SecurityPkg/AuthVariableLib: Fix ptr bad arithmetic.
Date: Mon, 16 Oct 2017 16:43:53 +0800 [thread overview]
Message-ID: <20171016084353.10212-1-chen.a.chen@intel.com> (raw)
Use variable instead of sizeof(UINT8) and sizeof(UINT32) to
avoid bad arithmetic of pointer.
Cc: chenc2 <chen.a.chen@intel.com>
Cc: Wu Hao A <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Cc: Zhang Chao B <chao.b.zhang@intel.com>
---
SecurityPkg/Library/AuthVariableLib/AuthService.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 7188ff6008..d6387d5ea6 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -2289,6 +2289,8 @@ VerifyTimeBasedPayload (
UINT8 *CertsInCertDb;
UINT32 CertsSizeinDb;
UINT8 Sha256Digest[SHA256_DIGEST_SIZE];
+ UINTN Offset1;
+ UINTN Offset2;
//
// 1. TopLevelCert is the top-level issuer certificate in signature Signer Cert Chain
@@ -2559,9 +2561,11 @@ VerifyTimeBasedPayload (
//
// Check hash of signer cert CommonName + Top-level issuer tbsCertificate against data in CertDb
//
+ Offset1 = sizeof (UINT8) + sizeof (UINT32);
+ Offset2 = sizeof (UINT8);
Status = CalculatePrivAuthVarSignChainSHA256Digest(
- SignerCerts + sizeof(UINT8) + sizeof(UINT32),
- ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+ SignerCerts + Offset1,
+ ReadUnaligned32 ((UINT32 *)(SignerCerts + Offset2)),
TopLevelCert,
TopLevelCertSize,
Sha256Digest
@@ -2596,12 +2600,14 @@ VerifyTimeBasedPayload (
//
// When adding a new common authenticated variable, always save Hash of cn of signer cert + tbsCertificate of Top-level issuer
//
+ Offset1 = sizeof (UINT8) + sizeof (UINT32);
+ Offset2 = sizeof (UINT8);
Status = InsertCertsToDb (
VariableName,
VendorGuid,
Attributes,
- SignerCerts + sizeof(UINT8) + sizeof(UINT32),
- ReadUnaligned32 ((UINT32 *)(SignerCerts + sizeof(UINT8))),
+ SignerCerts + Offset1,
+ ReadUnaligned32 ((UINT32 *)(SignerCerts + Offset2)),
TopLevelCert,
TopLevelCertSize
);
--
2.13.2.windows.1
next reply other threads:[~2017-10-16 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 8:43 chenc2 [this message]
2017-10-16 10:38 ` [PATCH] SecurityPkg/AuthVariableLib: Fix ptr bad arithmetic Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171016084353.10212-1-chen.a.chen@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox