]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
NetworkPkg/Tls: Fix few typos
[mirror_edk2.git] / NetworkPkg / TlsAuthConfigDxe / TlsAuthConfigImpl.c
index 7259c5e82f616fe1aefc3e92ac0b932b361f1823..715bc3a0a9414912e55307ffcc609cbe2b69a412 100644 (file)
@@ -3,13 +3,7 @@
 \r
 Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -304,7 +298,7 @@ ON_EXIT:
   @param[in]    QuestionIdBase      Base question id of the cert list.\r
   @param[in]    DeleteIndex         Cert index to delete.\r
 \r
-  @retval   EFI_SUCCESS             Delete siganture successfully.\r
+  @retval   EFI_SUCCESS             Delete signature successfully.\r
   @retval   EFI_NOT_FOUND           Can't find the signature item,\r
   @retval   EFI_OUT_OF_RESOURCES    Could not allocate needed resources.\r
 **/\r
@@ -603,7 +597,7 @@ DevicePathToStr (
 \r
   @param DevicePath       Device path.\r
 \r
-  @retval NULL            Not enough memory resourece for AllocateCopyPool.\r
+  @retval NULL            Not enough memory resource for AllocateCopyPool.\r
   @retval Other           A new allocated string that represents the file name.\r
 \r
 **/\r
@@ -663,6 +657,7 @@ EnrollX509toVariable (
   EFI_SIGNATURE_LIST                *CACert;\r
   EFI_SIGNATURE_DATA                *CACertData;\r
   VOID                              *Data;\r
+  VOID                              *CurrentData;\r
   UINTN                             DataSize;\r
   UINTN                             SigDataSize;\r
   UINT32                            Attr;\r
@@ -674,6 +669,7 @@ EnrollX509toVariable (
   CACert        = NULL;\r
   CACertData    = NULL;\r
   Data          = NULL;\r
+  CurrentData   = NULL;\r
   Attr          = 0;\r
 \r
   Status = ReadFileContent (\r
@@ -716,11 +712,30 @@ EnrollX509toVariable (
   Status = gRT->GetVariable(\r
                   VariableName,\r
                   &gEfiTlsCaCertificateGuid,\r
-                  &Attr,\r
+                  NULL,\r
                   &DataSize,\r
                   NULL\r
                   );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    //\r
+    // Per spec, we have to fetch the variable's contents, even though we're\r
+    // only interested in the variable's attributes.\r
+    //\r
+    CurrentData = AllocatePool (DataSize);\r
+    if (CurrentData == NULL) {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      goto ON_EXIT;\r
+    }\r
+    Status = gRT->GetVariable(\r
+                    VariableName,\r
+                    &gEfiTlsCaCertificateGuid,\r
+                    &Attr,\r
+                    &DataSize,\r
+                    CurrentData\r
+                    );\r
+    if (EFI_ERROR (Status)) {\r
+      goto ON_EXIT;\r
+    }\r
     Attr |= EFI_VARIABLE_APPEND_WRITE;\r
   } else if (Status == EFI_NOT_FOUND) {\r
     Attr = TLS_AUTH_CONFIG_VAR_BASE_ATTR;\r
@@ -751,6 +766,10 @@ ON_EXIT:
     FreePool (Data);\r
   }\r
 \r
+  if (CurrentData != NULL) {\r
+    FreePool (CurrentData);\r
+  }\r
+\r
   if (X509Data != NULL) {\r
     FreePool (X509Data);\r
   }\r
@@ -1284,7 +1303,7 @@ TlsAuthConfigAccessExtractConfig (
   @param Progress       A pointer to a string filled in with the\r
                         offset of the most recent '&' before the\r
                         first failing name / value pair (or the\r
-                        beginn ing of the string if the failure\r
+                        beginning of the string if the failure\r
                         is in the first name / value pair) or\r
                         the terminating NULL if all was\r
                         successful.\r