diff options
author | Star Zeng <star.zeng@intel.com> | 2018-03-15 13:50:31 +0800 |
---|---|---|
committer | Star Zeng <star.zeng@intel.com> | 2018-03-17 15:51:21 +0800 |
commit | ca0b3a0ef28eabcaf296f644d64c0a90598b4a9b (patch) | |
tree | 9f14e2712365fd26ff90938c101f53e5189674ef | |
parent | 5af1943160e78f525d04abc159d5befe0d05c1c8 (diff) | |
download | edk2-ca0b3a0ef28eabcaf296f644d64c0a90598b4a9b.tar.gz |
SecurityPkg OpalPasswordDxe:Fix wrong BufferSize input to UnicodeSPrint
Current code uses string length as BufferSize input to UnicodeSPrint,
it is wrong and makes the pop up string trimmed. The BufferSize input
to UnicodeSPrint should be the size, in bytes, of the output buffer.
This is to use sizeof (mPopUpString) as the BufferSize input to
UnicodeSPrint, it also updates array size of mPopUpString from 256 to
100 that is enough, otherwise the pop up string may be too long.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit aa0857304e83801ce8c673504625aa3307abb82f)
-rw-r--r-- | SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c index 1b55bbe4ec..4133e503e2 100644 --- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c +++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.c @@ -27,7 +27,7 @@ EFI_GUID mOpalDeviceNvmeGuid = OPAL_DEVICE_NVME_GUID; BOOLEAN mOpalEndOfDxe = FALSE;
OPAL_REQUEST_VARIABLE *mOpalRequestVariable = NULL;
UINTN mOpalRequestVariableSize = 0;
-CHAR16 mPopUpString[256];
+CHAR16 mPopUpString[100];
typedef struct {
UINT32 Address;
@@ -659,7 +659,7 @@ OpalEndOfDxeEventNotify ( @param[in] PopUpString Pop up string.
@param[out] PressEsc Whether user escape function through Press ESC.
- @retval Password string if success. NULL if failed.
+ @retval Psid string if success. NULL if failed.
**/
CHAR8 *
@@ -908,11 +908,13 @@ OpalDriverPopUpPasswordInput ( }
/**
- Check if disk is locked, show popup window and ask for password if it is.
+ Get pop up string.
- @param[in] Dev The device which need to be unlocked.
+ @param[in] Dev The OPAL device.
@param[in] RequestString Request string.
+ @return Pop up string.
+
**/
CHAR16 *
OpalGetPopUpString (
@@ -920,15 +922,10 @@ OpalGetPopUpString ( IN CHAR16 *RequestString
)
{
- UINTN StrLength;
-
- StrLength = StrLen (RequestString) + 1 + MAX (StrLen (Dev->Name16), StrLen (L"Disk"));
- ASSERT (StrLength < sizeof (mPopUpString) / sizeof (CHAR16));
-
if (Dev->Name16 == NULL) {
- UnicodeSPrint (mPopUpString, StrLength + 1, L"%s Disk", RequestString);
+ UnicodeSPrint (mPopUpString, sizeof (mPopUpString), L"%s Disk", RequestString);
} else {
- UnicodeSPrint (mPopUpString, StrLength + 1, L"%s %s", RequestString, Dev->Name16);
+ UnicodeSPrint (mPopUpString, sizeof (mPopUpString), L"%s %s", RequestString, Dev->Name16);
}
return mPopUpString;
|