public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Chris Phillips <chrisp@hpe.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
Date: Tue, 10 Jan 2017 10:08:57 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B8156BE@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <07736531-4229-420c-9676-99c2a5e59e5f@AIA2PHNNRN.local>

Chris,

Could you also correct the typo "Assert" to "Asset"?
With the typo fixed, Reviewed-by: Star Zeng <star.zeng@intel.com>

Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Chris Phillips
Sent: Tuesday, January 10, 2017 2:55 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: [edk2] [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length

When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hpe.com>
---
 .../MiscBaseBoardManufacturerFunction.c                  | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
index 303726c3fd..26d5d11da6 100644
--- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
+++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.
+++ c
@@ -3,6 +3,7 @@
   SMBIOS type 2.
   
 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
 This program and the accompanying materials  are licensed and made available under the terms and conditions of the BSD License  which accompanies this distribution.  The full text of the license may be found at @@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //
   // Two zeros following the last string.
   //
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof 
+ (UINT16) bytes for ContainedObjectHandles[1]  //  SmbiosRecord = 
+ AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
+ ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 
+ 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1);  
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
+ ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 
+ 1 + AssertTagStrLen + 1 + ChassisStrLen + 1 + 1);
 
   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
+  //
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof 
+ (UINT16) bytes for ContainedObjectHandles[1]  //  
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof 
+ (UINT16);
   //
   // Make handle chosen by smbios protocol.add automatically.
   //
@@ -142,9 +148,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
   //
-  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
+  // Since we fill NumberOfContainedObjectHandles = 0, just after this 
+ field to fill string
   //
-  OptionalStrStart -= 2;
+  OptionalStrStart -= sizeof (UINT16);
   UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
   UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
   UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
--
2.11.0.windows.1


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2017-01-10 10:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-10  6:55 [PATCH] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length Chris Phillips
2017-01-10 10:08 ` Zeng, Star [this message]
2017-01-10 16:41   ` Phillips, Chris J (Plano, TX)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B8156BE@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox