]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
StandaloneMmPkg: Describe the declaration and definition files.
[mirror_edk2.git] / NetworkPkg / TlsAuthConfigDxe / TlsAuthConfigImpl.c
index faefc72d0efa952a571703e74b8f9a948698b521..31450b3e4a1bf2882564184980ccbf7beabc5430 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The Miscellaneous Routines for TlsAuthConfigDxe driver.\r
 \r
-Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\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
@@ -813,6 +813,7 @@ EnrollX509toVariable (
   CACert        = NULL;\r
   CACertData    = NULL;\r
   Data          = NULL;\r
+  Attr          = 0;\r
 \r
   Status = ReadFileContent (\r
              Private->FileContext->FHandle,\r
@@ -847,22 +848,22 @@ EnrollX509toVariable (
   CopyMem ((UINT8* ) (CACertData->SignatureData), X509Data, X509DataSize);\r
 \r
   //\r
-  // Check if signature database entry has been already existed.\r
-  // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the\r
-  // new signature data to original variable\r
+  // Check if the signature database entry already exists. If it does, use the\r
+  // EFI_VARIABLE_APPEND_WRITE attribute to append the new signature data to\r
+  // the original variable, plus preserve the original variable attributes.\r
   //\r
-  Attr = TLS_AUTH_CONFIG_VAR_BASE_ATTR;\r
-\r
   Status = gRT->GetVariable(\r
                   VariableName,\r
                   &gEfiTlsCaCertificateGuid,\r
-                  NULL,\r
+                  &Attr,\r
                   &DataSize,\r
                   NULL\r
                   );\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     Attr |= EFI_VARIABLE_APPEND_WRITE;\r
-  } else if (Status != EFI_NOT_FOUND) {\r
+  } else if (Status == EFI_NOT_FOUND) {\r
+    Attr = TLS_AUTH_CONFIG_VAR_BASE_ATTR;\r
+  } else {\r
     goto ON_EXIT;\r
   }\r
 \r
@@ -1559,7 +1560,7 @@ TlsAuthConfigAccessCallback (
   HiiGetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, BufferSize, (UINT8 *) IfrNvData);\r
 \r
   if ((Action != EFI_BROWSER_ACTION_CHANGED) &&\r
-      (Action != EFI_BROWSER_ACTION_CHANGING) && \r
+      (Action != EFI_BROWSER_ACTION_CHANGING) &&\r
       (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
     Status = EFI_UNSUPPORTED;\r
     goto EXIT;\r
@@ -1592,10 +1593,10 @@ TlsAuthConfigAccessCallback (
       break;\r
     case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE:\r
       //\r
-      // If the file is already opened, clean the file related resource first. \r
+      // If the file is already opened, clean the file related resource first.\r
       //\r
       CleanFileContext (Private);\r
-      \r
+\r
       ChooseFile( NULL, NULL, UpdateCAFromFile, &File);\r
       break;\r
 \r