]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg/SecureBootConfigDxe: Use StrToGuid in BaseLib
authorRuiyu Ni <ruiyu.ni@intel.com>
Tue, 21 Feb 2017 09:13:12 +0000 (17:13 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 28 Feb 2017 03:30:34 +0000 (11:30 +0800)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.h
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigMisc.c

index 6f587291e226ed901b58b438fbc5c3ba8923a660..16ca9578ba0e3b201b2938bfa5df06827e695b81 100644 (file)
@@ -3248,6 +3248,7 @@ SecureBootCallback (
 {\r
   EFI_INPUT_KEY                   Key;\r
   EFI_STATUS                      Status;\r
+  RETURN_STATUS                   RStatus;\r
   SECUREBOOT_CONFIG_PRIVATE_DATA  *Private;\r
   UINTN                           BufferSize;\r
   SECUREBOOT_CONFIGURATION        *IfrNvData;\r
@@ -3630,12 +3631,9 @@ SecureBootCallback (
     case KEY_SECURE_BOOT_SIGNATURE_GUID_DBX:\r
     case KEY_SECURE_BOOT_SIGNATURE_GUID_DBT:\r
       ASSERT (Private->SignatureGUID != NULL);\r
-      Status = StringToGuid (\r
-                 IfrNvData->SignatureGuid,\r
-                 StrLen (IfrNvData->SignatureGuid),\r
-                 Private->SignatureGUID\r
-                 );\r
-      if (EFI_ERROR (Status)) {\r
+      RStatus = StrToGuid (IfrNvData->SignatureGuid, Private->SignatureGUID);\r
+      if (RETURN_ERROR (RStatus) || (IfrNvData->SignatureGuid[GUID_STRING_LENGTH] != L'\0')) {\r
+        Status = EFI_INVALID_PARAMETER;\r
         break;\r
       }\r
 \r
index bea9470eae60170533e3b42e421d24850d7b92c5..d438d37e04b0f94d4afd58bea96f5736b71af9f4 100644 (file)
@@ -475,26 +475,6 @@ Int2OctStr (
   IN     UINTN             OSSizeInBytes\r
   );\r
 \r
-\r
-/**\r
-  Convert a String to Guid Value.\r
-\r
-  @param[in]   Str        Specifies the String to be converted.\r
-  @param[in]   StrLen     Number of Unicode Characters of String (exclusive \0)\r
-  @param[out]  Guid       Return the result Guid value.\r
-\r
-  @retval    EFI_SUCCESS           The operation is finished successfully.\r
-  @retval    EFI_NOT_FOUND         Invalid string.\r
-\r
-**/\r
-EFI_STATUS\r
-StringToGuid (\r
-  IN   CHAR16           *Str,\r
-  IN   UINTN            StrLen,\r
-  OUT  EFI_GUID         *Guid\r
-  );\r
-\r
-\r
 /**\r
   Worker function that prints an EFI_GUID into specified Buffer.\r
 \r
index a83504e78734854e9f95787a4f6cc6008efbcc76..038707ca833c617405f3583b4d5dc81fde4cc507 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Helper functions for SecureBoot configuration module.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -152,145 +152,6 @@ Int2OctStr (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-\r
-/**\r
-  Convert a String to Guid Value.\r
-\r
-  @param[in]   Str        Specifies the String to be converted.\r
-  @param[in]   StrLen     Number of Unicode Characters of String (exclusive \0)\r
-  @param[out]  Guid       Return the result Guid value.\r
-\r
-  @retval    EFI_SUCCESS           The operation is finished successfully.\r
-  @retval    EFI_NOT_FOUND         Invalid string.\r
-\r
-**/\r
-EFI_STATUS\r
-StringToGuid (\r
-  IN   CHAR16           *Str, \r
-  IN   UINTN            StrLen, \r
-  OUT  EFI_GUID         *Guid\r
-  )\r
-{\r
-  CHAR16             *PtrBuffer;\r
-  CHAR16             *PtrPosition;\r
-  UINT16             *Buffer;\r
-  UINTN              Data;\r
-  UINTN              Index;\r
-  UINT16             Digits[3];\r
-\r
-  Buffer = (CHAR16 *) AllocateZeroPool (sizeof (CHAR16) * (StrLen + 1));\r
-  if (Buffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  StrCpyS (Buffer, (StrLen + 1), Str);\r
-\r
-  //\r
-  // Data1\r
-  //\r
-  PtrBuffer       = Buffer;\r
-  PtrPosition     = PtrBuffer; \r
-  while (*PtrBuffer != L'\0') {\r
-    if (*PtrBuffer == L'-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == L'\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  *PtrBuffer      = L'\0';\r
-  Data            = StrHexToUintn (PtrPosition);\r
-  Guid->Data1     = (UINT32)Data;\r
-\r
-  //\r
-  // Data2\r
-  //\r
-  PtrBuffer++;\r
-  PtrPosition     = PtrBuffer;\r
-  while (*PtrBuffer != L'\0') {\r
-    if (*PtrBuffer == L'-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == L'\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  *PtrBuffer      = L'\0';\r
-  Data            = StrHexToUintn (PtrPosition);\r
-  Guid->Data2     = (UINT16)Data;\r
-\r
-  //\r
-  // Data3\r
-  //\r
-  PtrBuffer++;\r
-  PtrPosition     = PtrBuffer;\r
-  while (*PtrBuffer != L'\0') {\r
-    if (*PtrBuffer == L'-') {\r
-      break;\r
-    }\r
-    PtrBuffer++;\r
-  }\r
-  if (*PtrBuffer == L'\0') {\r
-    FreePool (Buffer);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  *PtrBuffer      = L'\0';\r
-  Data            = StrHexToUintn (PtrPosition);\r
-  Guid->Data3     = (UINT16)Data;\r
-\r
-  //\r
-  // Data4[0..1]\r
-  //\r
-  for ( Index = 0 ; Index < 2 ; Index++) {\r
-    PtrBuffer++;\r
-    if ((*PtrBuffer == L'\0') || ( *(PtrBuffer + 1) == L'\0')) {\r
-      FreePool (Buffer);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    Digits[0]     = *PtrBuffer;\r
-    PtrBuffer++;\r
-    Digits[1]     = *PtrBuffer;\r
-    Digits[2]     = L'\0';\r
-    Data          = StrHexToUintn (Digits);\r
-    Guid->Data4[Index] = (UINT8)Data;\r
-  }\r
-\r
-  //\r
-  // skip the '-'\r
-  //\r
-  PtrBuffer++;\r
-  if ((*PtrBuffer != L'-' ) || ( *PtrBuffer == L'\0')) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-\r
-  //\r
-  // Data4[2..7]\r
-  //\r
-  for ( ; Index < 8; Index++) {\r
-    PtrBuffer++;\r
-    if ((*PtrBuffer == L'\0') || ( *(PtrBuffer + 1) == L'\0')) {\r
-      FreePool (Buffer);\r
-      return EFI_NOT_FOUND;\r
-    }\r
-    Digits[0]     = *PtrBuffer;\r
-    PtrBuffer++;\r
-    Digits[1]     = *PtrBuffer;\r
-    Digits[2]     = L'\0';\r
-    Data          = StrHexToUintn (Digits);\r
-    Guid->Data4[Index] = (UINT8)Data;\r
-  }\r
-\r
-  FreePool (Buffer);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
 /**\r
   Worker function that prints an EFI_GUID into specified Buffer.\r
 \r