From: Eric Dong <eric.dong@intel.com>
To: edk2-devel@lists.01.org
Cc: Feng Tian <feng.tian@intel.com>, Jiewen Yao <jiewen.yao@intel.com>
Subject: [Patch 1/2] SecurityPkg OpalPasswordDxe: Clean password buffer.
Date: Wed, 16 Nov 2016 14:15:29 +0800 [thread overview]
Message-ID: <1479276930-31360-2-git-send-email-eric.dong@intel.com> (raw)
In-Reply-To: <1479276930-31360-1-git-send-email-eric.dong@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c | 1 +
SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c | 17 +++++++++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
index 718d49e..0a32ee2 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalDriver.c
@@ -240,6 +240,7 @@ OpalDriverPopUpHddPassword (
}
UnicodeStrToAsciiStrS (Unicode, Ascii, MAX_PASSWORD_SIZE + 1);
+ ZeroMem (Unicode, sizeof (Unicode));
return Ascii;
}
diff --git a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
index 5e3106a..5937ce2 100644
--- a/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPasswordDxe/OpalHii.c
@@ -694,6 +694,8 @@ HiiPsidRevert(
Ret = OpalSupportPsidRevert(&Session, Psid.Psid, (UINT32)sizeof(Psid.Psid), OpalDisk->OpalDevicePath);
}
+ ZeroMem (Psid.Psid, PSID_CHARACTER_LENGTH);
+
if (Ret == TcgResultSuccess) {
AsciiSPrint( Response, DEFAULT_RESPONSE_SIZE, "%a", "PSID Revert: Success" );
} else {
@@ -1099,8 +1101,8 @@ HiiPasswordEntered(
EFI_STRING_ID Str
)
{
- OPAL_DISK* OpalDisk;
- CHAR8 Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
+ OPAL_DISK* OpalDisk;
+ CHAR8 Password[MAX_PASSWORD_CHARACTER_LENGTH + 1];
CHAR16* UniStr;
UINT32 PassLength;
EFI_STATUS Status;
@@ -1124,15 +1126,20 @@ HiiPasswordEntered(
if (UniStr == NULL) {
return EFI_NOT_FOUND;
}
+
+ HiiSetString(gHiiPackageListHandle, Str, L"", NULL);
+
PassLength = (UINT32) StrLen (UniStr);
if (PassLength >= sizeof(Password)) {
HiiSetFormString(STRING_TOKEN(STR_ACTION_STATUS), "Password too long");
- gBS->FreePool(UniStr);
+ ZeroMem (UniStr, StrSize (UniStr));
+ FreePool(UniStr);
return EFI_BUFFER_TOO_SMALL;
}
UnicodeStrToAsciiStrS (UniStr, Password, sizeof (Password));
- gBS->FreePool(UniStr);
+ ZeroMem (UniStr, StrSize (UniStr));
+ FreePool(UniStr);
if (gHiiConfiguration.SelectedAction == HII_KEY_ID_GOTO_UNLOCK) {
Status = HiiUnlock (OpalDisk, Password, PassLength);
@@ -1154,6 +1161,8 @@ HiiPasswordEntered(
Status = HiiSetPassword(OpalDisk, Password, PassLength);
}
+ ZeroMem (Password, sizeof (Password));
+
OpalHiiSetBrowserData ();
return Status;
--
2.6.4.windows.1
next prev parent reply other threads:[~2016-11-16 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 6:15 [Patch 0/2] Clean the temp buffer after using it Eric Dong
2016-11-16 6:15 ` Eric Dong [this message]
2016-11-17 8:46 ` [Patch 1/2] SecurityPkg OpalPasswordDxe: Clean password buffer Yao, Jiewen
2016-11-16 6:15 ` [Patch 2/2] SecurityPkg OpalPasswordDxe: Clean PSID buffer Eric Dong
2016-11-17 8:45 ` Yao, Jiewen
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=1479276930-31360-2-git-send-email-eric.dong@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