]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Library/Tpm12CommandLib/Tpm12NvStorage.c
SecurityPkg: Fix TPM 1.2 NV Storage Command Size byte order
[mirror_edk2.git] / SecurityPkg / Library / Tpm12CommandLib / Tpm12NvStorage.c
index 7baafa8f55be2568cb3c4ab61e175be008b95393..e176b00f6bc8f78c2156864637e2fd9a736747aa 100644 (file)
@@ -2,6 +2,7 @@
   Implement TPM1.2 NV storage related command.\r
 \r
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved. <BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -199,8 +200,9 @@ Tpm12NvWriteValue (
 {\r
   EFI_STATUS              Status;\r
   TPM_CMD_NV_WRITE_VALUE  Command;\r
+  UINT32                  CommandLength;\r
   TPM_RSP_COMMAND_HDR     Response;\r
-  UINT32                  Length;\r
+  UINT32                  ResponseLength;\r
 \r
   if (DataSize > sizeof (Command.Data)) {\r
     return EFI_UNSUPPORTED;\r
@@ -210,14 +212,15 @@ Tpm12NvWriteValue (
   // send Tpm command TPM_ORD_NV_WriteValue\r
   //\r
   Command.Hdr.tag       = SwapBytes16 (TPM_TAG_RQU_COMMAND);\r
-  Command.Hdr.paramSize = SwapBytes32 (sizeof (Command) - sizeof(Command.Data) + DataSize);\r
+  CommandLength = sizeof (Command) - sizeof(Command.Data) + DataSize;\r
+  Command.Hdr.paramSize = SwapBytes32 (CommandLength);\r
   Command.Hdr.ordinal   = SwapBytes32 (TPM_ORD_NV_WriteValue);\r
   Command.NvIndex       = SwapBytes32 (NvIndex);\r
   Command.Offset        = SwapBytes32 (Offset);\r
   Command.DataSize      = SwapBytes32 (DataSize);\r
   CopyMem (Command.Data, Data, DataSize);\r
-  Length = sizeof (Response);\r
-  Status = Tpm12SubmitCommand (Command.Hdr.paramSize, (UINT8 *)&Command, &Length, (UINT8 *)&Response);\r
+  ResponseLength = sizeof (Response);\r
+  Status = Tpm12SubmitCommand (CommandLength, (UINT8 *)&Command, &ResponseLength, (UINT8 *)&Response);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r