public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines.
@ 2023-04-28 18:52 Giri Mudusuru
  2023-04-28 18:52 ` [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings Giri Mudusuru
  2023-05-04  7:53 ` 回复: [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines gaoliming
  0 siblings, 2 replies; 6+ messages in thread
From: Giri Mudusuru @ 2023-04-28 18:52 UTC (permalink / raw)
  To: devel
  Cc: Giri Mudusuru, Michael D Kinney, Liming Gao, Zhiguang Liu,
	Andrew Fish

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 2318 bytes --]

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805

Add SMBIOS spec defined anchor strings & length defines.

 - '_SM_' chapter 5.2.1 SMBIOS 2.1 (32-bit) Entry Point
 - '_SM3_' chapter 5.2.2 SMBIOS 3.0 (64-bit) Entry Point

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Signed-off-by: Giri Mudusuru <girim@apple.com>
---
 MdePkg/Include/IndustryStandard/SmBios.h | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h b/MdePkg/Include/IndustryStandard/SmBios.h
index 9cbdec1182..4c560e758b 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -48,6 +48,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //
 #define SMBIOS_3_0_TABLE_MAX_LENGTH  0xFFFFFFFF
 
+///
+/// Reference SMBIOS 3.4, chapter 5.2.1 SMBIOS 2.1 (32-bit) Entry Point
+/// Table 1 – SMBIOS 2.1 (32-bit) Entry Point structure, offset 00h
+/// _SM_, specified as four ASCII characters (5F 53 4D 5F).
+///@{
+#define SMBIOS_ANCHOR_STRING         "_SM_"
+#define SMBIOS_ANCHOR_STRING_LENGTH  4
+///@}
+
+///
+/// Reference SMBIOS 3.4, chapter 5.2.2 SMBIOS 3.0 (64-bit) Entry Point
+/// Table 2 – SMBIOS 3.0 (64-bit) Entry Point structure, offset 00h
+/// _SM3_, specified as five ASCII characters (5F 53 4D 33 5F).
+///@{
+#define SMBIOS_3_0_ANCHOR_STRING         "_SM3_"
+#define SMBIOS_3_0_ANCHOR_STRING_LENGTH  5
+///@}
+
 //
 // SMBIOS type macros which is according to SMBIOS 3.3.0 specification.
 //
@@ -138,7 +156,7 @@ typedef UINT16 SMBIOS_HANDLE;
 ///
 #pragma pack(1)
 typedef struct {
-  UINT8     AnchorString[4];
+  UINT8     AnchorString[SMBIOS_ANCHOR_STRING_LENGTH];
   UINT8     EntryPointStructureChecksum;
   UINT8     EntryPointLength;
   UINT8     MajorVersion;
@@ -155,7 +173,7 @@ typedef struct {
 } SMBIOS_TABLE_ENTRY_POINT;
 
 typedef struct {
-  UINT8     AnchorString[5];
+  UINT8     AnchorString[SMBIOS_3_0_ANCHOR_STRING_LENGTH];
   UINT8     EntryPointStructureChecksum;
   UINT8     EntryPointLength;
   UINT8     MajorVersion;
-- 
2.39.2 (Apple Git-144)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
  2023-04-28 18:52 [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines Giri Mudusuru
@ 2023-04-28 18:52 ` Giri Mudusuru
  2023-05-04  7:57   ` 回复: " gaoliming
       [not found]   ` <175BE1BE3E9B8CC1.28444@groups.io>
  2023-05-04  7:53 ` 回复: [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines gaoliming
  1 sibling, 2 replies; 6+ messages in thread
From: Giri Mudusuru @ 2023-04-28 18:52 UTC (permalink / raw)
  To: devel
  Cc: Giri Mudusuru, Michael D Kinney, Liming Gao, Zhiguang Liu,
	Andrew Fish

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805

Replace hardcoded SMBIOS Anchor string and size with defines.

Fix buffer overflow as described below.

Smbios64BitPrintEPSInfo () is coded like:
UINT8  Anchor[5];

MemToString (Anchor, SmbiosTable->AnchorString, 5);

But the definition of MemToString()
  Copy Length of Src buffer to Dest buffer,
  add a NULL termination to Dest buffer.

So Anchor needs to be +1 the size of the SMBIOS Anchor string `_SM3_`.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Signed-off-by: Giri Mudusuru <girim@apple.com>
---
 .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c    | 9 +++++----
 .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c   | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index 1811cf0c44..dd190b006f 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -5,6 +5,7 @@
   Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
   (C) Copyright 2015-2019 Hewlett Packard Enterprise Development LP<BR>
+  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -135,7 +136,7 @@ SmbiosPrintEPSInfo (
   IN  UINT8                     Option
   )
 {
-  UINT8  Anchor[5];
+  UINT8  Anchor[SMBIOS_ANCHOR_STRING_LENGTH + 1]; ///< Including terminating NULL character
   UINT8  InAnchor[6];
 
   if (SmbiosTable == NULL) {
@@ -149,7 +150,7 @@ SmbiosPrintEPSInfo (
 
   if (Option >= SHOW_NORMAL) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN), gShellDebug1HiiHandle);
-    MemToString (Anchor, SmbiosTable->AnchorString, 4);
+    MemToString (Anchor, SmbiosTable->AnchorString, SMBIOS_ANCHOR_STRING_LENGTH);
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle, Anchor);
     ShellPrintHiiEx (
       -1,
@@ -220,7 +221,7 @@ Smbios64BitPrintEPSInfo (
   IN  UINT8                         Option
   )
 {
-  UINT8  Anchor[5];
+  UINT8  Anchor[SMBIOS_3_0_ANCHOR_STRING_LENGTH + 1]; ///< Including terminating NULL character
 
   if (SmbiosTable == NULL) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL), gShellDebug1HiiHandle);
@@ -234,7 +235,7 @@ Smbios64BitPrintEPSInfo (
   if (Option >= SHOW_NORMAL) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN), gShellDebug1HiiHandle);
 
-    MemToString (Anchor, SmbiosTable->AnchorString, 5);
+    MemToString (Anchor, SmbiosTable->AnchorString, SMBIOS_3_0_ANCHOR_STRING_LENGTH);
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle, Anchor);
 
     ShellPrintHiiEx (
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
index e9360beb23..7e7eef3fd8 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
@@ -3,6 +3,7 @@
 
   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
   Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -263,7 +264,7 @@ SMBiosView (
     return EFI_BAD_BUFFER_SIZE;
   }
 
-  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) {
+  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING, SMBIOS_ANCHOR_STRING_LENGTH) == 0) {
     //
     // Have got SMBIOS table
     //
@@ -441,7 +442,7 @@ SMBios64View (
     return EFI_BAD_BUFFER_SIZE;
   }
 
-  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) == 0) {
+  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH) == 0) {
     //
     // Have got SMBIOS table
     //
@@ -612,7 +613,7 @@ InitSmbiosTableStatistics (
     return EFI_NOT_FOUND;
   }
 
-  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) {
+  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING, SMBIOS_ANCHOR_STRING_LENGTH) != 0) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
     return EFI_INVALID_PARAMETER;
   }
@@ -753,7 +754,7 @@ InitSmbios64BitTableStatistics (
     return EFI_NOT_FOUND;
   }
 
-  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) != 0) {
+  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH) != 0) {
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
     return EFI_INVALID_PARAMETER;
   }
-- 
2.39.2 (Apple Git-144)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* 回复: [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines.
  2023-04-28 18:52 [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines Giri Mudusuru
  2023-04-28 18:52 ` [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings Giri Mudusuru
@ 2023-05-04  7:53 ` gaoliming
  1 sibling, 0 replies; 6+ messages in thread
From: gaoliming @ 2023-05-04  7:53 UTC (permalink / raw)
  To: 'Giri Mudusuru', devel
  Cc: 'Michael D Kinney', 'Zhiguang Liu',
	'Andrew Fish'

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 3106 bytes --]

Giri:

> -----ÓʼþÔ­¼þ-----
> ·¢¼þÈË: Giri Mudusuru <girim@apple.com>
> ·¢ËÍʱ¼ä: 2023Äê4ÔÂ29ÈÕ 2:53
> ÊÕ¼þÈË: devel@edk2.groups.io
> ³­ËÍ: Giri Mudusuru <girim@apple.com>; Michael D Kinney
> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> Zhiguang Liu <zhiguang.liu@intel.com>; Andrew Fish <afish@apple.com>
> Ö÷Ìâ: [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string &
> length defines.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805
> 
> Add SMBIOS spec defined anchor strings & length defines.
> 
>  - '_SM_' chapter 5.2.1 SMBIOS 2.1 (32-bit) Entry Point
>  - '_SM3_' chapter 5.2.2 SMBIOS 3.0 (64-bit) Entry Point
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Signed-off-by: Giri Mudusuru <girim@apple.com>
> ---
>  MdePkg/Include/IndustryStandard/SmBios.h | 22
> ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/MdePkg/Include/IndustryStandard/SmBios.h
> b/MdePkg/Include/IndustryStandard/SmBios.h
> index 9cbdec1182..4c560e758b 100644
> --- a/MdePkg/Include/IndustryStandard/SmBios.h
> +++ b/MdePkg/Include/IndustryStandard/SmBios.h
> @@ -48,6 +48,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  //
> 
>  #define SMBIOS_3_0_TABLE_MAX_LENGTH  0xFFFFFFFF
> 
> 
> 
> +///
> 
> +/// Reference SMBIOS 3.4, chapter 5.2.1 SMBIOS 2.1 (32-bit) Entry Point
> 
> +/// Table 1 �SMBIOS 2.1 (32-bit) Entry Point structure, offset 00h
> 
Please fix the non-ascii char here.

> +/// _SM_, specified as four ASCII characters (5F 53 4D 5F).
> 
> +///@{
> 
> +#define SMBIOS_ANCHOR_STRING         "_SM_"
> 
> +#define SMBIOS_ANCHOR_STRING_LENGTH  4
> 
> +///@}
> 
> +
> 
> +///
> 
> +/// Reference SMBIOS 3.4, chapter 5.2.2 SMBIOS 3.0 (64-bit) Entry Point
> 
> +/// Table 2 �SMBIOS 3.0 (64-bit) Entry Point structure, offset 00h

Please fix the non-ascii char here.

Thanks
Liming
> 
> +/// _SM3_, specified as five ASCII characters (5F 53 4D 33 5F).
> 
> +///@{
> 
> +#define SMBIOS_3_0_ANCHOR_STRING         "_SM3_"
> 
> +#define SMBIOS_3_0_ANCHOR_STRING_LENGTH  5
> 
> +///@}
> 
> +
> 
>  //
> 
>  // SMBIOS type macros which is according to SMBIOS 3.3.0 specification.
> 
>  //
> 
> @@ -138,7 +156,7 @@ typedef UINT16 SMBIOS_HANDLE;
>  ///
> 
>  #pragma pack(1)
> 
>  typedef struct {
> 
> -  UINT8     AnchorString[4];
> 
> +  UINT8     AnchorString[SMBIOS_ANCHOR_STRING_LENGTH];
> 
>    UINT8     EntryPointStructureChecksum;
> 
>    UINT8     EntryPointLength;
> 
>    UINT8     MajorVersion;
> 
> @@ -155,7 +173,7 @@ typedef struct {
>  } SMBIOS_TABLE_ENTRY_POINT;
> 
> 
> 
>  typedef struct {
> 
> -  UINT8     AnchorString[5];
> 
> +  UINT8     AnchorString[SMBIOS_3_0_ANCHOR_STRING_LENGTH];
> 
>    UINT8     EntryPointStructureChecksum;
> 
>    UINT8     EntryPointLength;
> 
>    UINT8     MajorVersion;
> 
> --
> 2.39.2 (Apple Git-144)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* 回复: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
  2023-04-28 18:52 ` [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings Giri Mudusuru
@ 2023-05-04  7:57   ` gaoliming
       [not found]   ` <175BE1BE3E9B8CC1.28444@groups.io>
  1 sibling, 0 replies; 6+ messages in thread
From: gaoliming @ 2023-05-04  7:57 UTC (permalink / raw)
  To: 'Giri Mudusuru', devel
  Cc: 'Michael D Kinney', 'Zhiguang Liu',
	'Andrew Fish'

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Giri Mudusuru <girim@apple.com>
> 发送时间: 2023年4月29日 2:53
> 收件人: devel@edk2.groups.io
> 抄送: Giri Mudusuru <girim@apple.com>; Michael D Kinney
> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> Zhiguang Liu <zhiguang.liu@intel.com>; Andrew Fish <afish@apple.com>
> 主题: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace
> hardcoded SMBIOS strings.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805
> 
> Replace hardcoded SMBIOS Anchor string and size with defines.
> 
> Fix buffer overflow as described below.
> 
> Smbios64BitPrintEPSInfo () is coded like:
> UINT8  Anchor[5];
> 
> MemToString (Anchor, SmbiosTable->AnchorString, 5);
> 
> But the definition of MemToString()
>   Copy Length of Src buffer to Dest buffer,
>   add a NULL termination to Dest buffer.
> 
> So Anchor needs to be +1 the size of the SMBIOS Anchor string `_SM3_`.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Andrew Fish <afish@apple.com>
> Signed-off-by: Giri Mudusuru <girim@apple.com>
> ---
>  .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c    | 9 +++++----
>  .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c   | 9
> +++++----
>  2 files changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> index 1811cf0c44..dd190b006f 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> @@ -5,6 +5,7 @@
>    Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>
> 
>    (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
> 
>    (C) Copyright 2015-2019 Hewlett Packard Enterprise Development
> LP<BR>
> 
> +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -135,7 +136,7 @@ SmbiosPrintEPSInfo (
>    IN  UINT8                     Option
> 
>    )
> 
>  {
> 
> -  UINT8  Anchor[5];
> 
> +  UINT8  Anchor[SMBIOS_ANCHOR_STRING_LENGTH + 1]; ///< Including
> terminating NULL character
> 
>    UINT8  InAnchor[6];
> 
> 
> 
>    if (SmbiosTable == NULL) {
> 
> @@ -149,7 +150,7 @@ SmbiosPrintEPSInfo (
> 
> 
>    if (Option >= SHOW_NORMAL) {
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN),
> gShellDebug1HiiHandle);
> 
> -    MemToString (Anchor, SmbiosTable->AnchorString, 4);
> 
> +    MemToString (Anchor, SmbiosTable->AnchorString,
> SMBIOS_ANCHOR_STRING_LENGTH);
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> Anchor);
> 
>      ShellPrintHiiEx (
> 
>        -1,
> 
> @@ -220,7 +221,7 @@ Smbios64BitPrintEPSInfo (
>    IN  UINT8                         Option
> 
>    )
> 
>  {
> 
> -  UINT8  Anchor[5];
> 
> +  UINT8  Anchor[SMBIOS_3_0_ANCHOR_STRING_LENGTH + 1]; ///<
> Including terminating NULL character
> 
> 
> 
>    if (SmbiosTable == NULL) {
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL),
> gShellDebug1HiiHandle);
> 
> @@ -234,7 +235,7 @@ Smbios64BitPrintEPSInfo (
>    if (Option >= SHOW_NORMAL) {
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN),
> gShellDebug1HiiHandle);
> 
> 
> 
> -    MemToString (Anchor, SmbiosTable->AnchorString, 5);
> 
> +    MemToString (Anchor, SmbiosTable->AnchorString,
> SMBIOS_3_0_ANCHOR_STRING_LENGTH);
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> Anchor);
> 
> 
> 
>      ShellPrintHiiEx (
> 
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> index e9360beb23..7e7eef3fd8 100644
> ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> @@ -3,6 +3,7 @@
> 
> 
>    (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
> 
>    Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
> 
> +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
>  **/
> 
> @@ -263,7 +264,7 @@ SMBiosView (
>      return EFI_BAD_BUFFER_SIZE;
> 
>    }
> 
> 
> 
> -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) {
> 
> +  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING,
> SMBIOS_ANCHOR_STRING_LENGTH) == 0) {
> 
>      //
> 
>      // Have got SMBIOS table
> 
>      //
> 
> @@ -441,7 +442,7 @@ SMBios64View (
>      return EFI_BAD_BUFFER_SIZE;
> 
>    }
> 
> 
> 
> -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) == 0) {
> 
> +  if (CompareMem (SMBiosTable->AnchorString,
> SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH)
> == 0) {
> 
>      //
> 
>      // Have got SMBIOS table
> 
>      //
> 
> @@ -612,7 +613,7 @@ InitSmbiosTableStatistics (
>      return EFI_NOT_FOUND;
> 
>    }
> 
> 
> 
> -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) {
> 
> +  if (CompareMem (SMBiosTable->AnchorString, SMBIOS_ANCHOR_STRING,
> SMBIOS_ANCHOR_STRING_LENGTH) != 0) {
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
> 
>      return EFI_INVALID_PARAMETER;
> 
>    }
> 
> @@ -753,7 +754,7 @@ InitSmbios64BitTableStatistics (
>      return EFI_NOT_FOUND;
> 
>    }
> 
> 
> 
> -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) != 0) {
> 
> +  if (CompareMem (SMBiosTable->AnchorString,
> SMBIOS_3_0_ANCHOR_STRING,
> SMBIOS_3_0_ANCHOR_STRING_LENGTH) != 0) {
> 
>      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE), gShellDebug1HiiHandle);
> 
>      return EFI_INVALID_PARAMETER;
> 
>    }
> 
> --
> 2.39.2 (Apple Git-144)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* 回复: [edk2-devel] 回复: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
       [not found]   ` <175BE1BE3E9B8CC1.28444@groups.io>
@ 2023-05-06  6:55     ` gaoliming
  2023-05-06 10:00       ` [edk2-devel] " Giri Mudusuru
  0 siblings, 1 reply; 6+ messages in thread
From: gaoliming @ 2023-05-06  6:55 UTC (permalink / raw)
  To: devel, gaoliming, 'Giri Mudusuru'
  Cc: 'Michael D Kinney', 'Zhiguang Liu',
	'Andrew Fish'

Giri:
  I create PR https://github.com/tianocore/edk2/pull/4350 to merge this
patch. But, Open CI reports the below issue. Please help fix them. 

ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 9004
ERROR - *For comment line with '///< ... text ...' format, if it is used, it
should be after the code section
ERROR - *file:
//__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
andsLib/SmbiosView/PrintInfo.c
ERROR - *Line number: 139
ERROR - *
ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 9004
ERROR - *For comment line with '///< ... text ...' format, if it is used, it
should be after the code section
ERROR - *file:
//__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
andsLib/SmbiosView/PrintInfo.c
ERROR - *Line number: 224
ERROR - *

Thanks
Liming
> -----邮件原件-----
> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 gaoliming via
> groups.io
> 发送时间: 2023年5月4日 15:57
> 收件人: 'Giri Mudusuru' <girim@apple.com>; devel@edk2.groups.io
> 抄送: 'Michael D Kinney' <michael.d.kinney@intel.com>; 'Zhiguang Liu'
> <zhiguang.liu@intel.com>; 'Andrew Fish' <afish@apple.com>
> 主题: [edk2-devel] 回复: [PATCH 2/2]
> ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
> 
> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
> 
> > -----邮件原件-----
> > 发件人: Giri Mudusuru <girim@apple.com>
> > 发送时间: 2023年4月29日 2:53
> > 收件人: devel@edk2.groups.io
> > 抄送: Giri Mudusuru <girim@apple.com>; Michael D Kinney
> > <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> > Zhiguang Liu <zhiguang.liu@intel.com>; Andrew Fish <afish@apple.com>
> > 主题: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace
> > hardcoded SMBIOS strings.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805
> >
> > Replace hardcoded SMBIOS Anchor string and size with defines.
> >
> > Fix buffer overflow as described below.
> >
> > Smbios64BitPrintEPSInfo () is coded like:
> > UINT8  Anchor[5];
> >
> > MemToString (Anchor, SmbiosTable->AnchorString, 5);
> >
> > But the definition of MemToString()
> >   Copy Length of Src buffer to Dest buffer,
> >   add a NULL termination to Dest buffer.
> >
> > So Anchor needs to be +1 the size of the SMBIOS Anchor string `_SM3_`.
> >
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> > Cc: Andrew Fish <afish@apple.com>
> > Signed-off-by: Giri Mudusuru <girim@apple.com>
> > ---
> >  .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c    | 9
> +++++----
> >  .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c   | 9
> > +++++----
> >  2 files changed, 10 insertions(+), 8 deletions(-)
> >
> > diff --git
> > a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > index 1811cf0c44..dd190b006f 100644
> > ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > +++
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > @@ -5,6 +5,7 @@
> >    Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>
> >
> >    (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
> >
> >    (C) Copyright 2015-2019 Hewlett Packard Enterprise Development
> > LP<BR>
> >
> > +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
> >
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> >  **/
> >
> > @@ -135,7 +136,7 @@ SmbiosPrintEPSInfo (
> >    IN  UINT8                     Option
> >
> >    )
> >
> >  {
> >
> > -  UINT8  Anchor[5];
> >
> > +  UINT8  Anchor[SMBIOS_ANCHOR_STRING_LENGTH + 1]; ///<
> Including
> > terminating NULL character
> >
> >    UINT8  InAnchor[6];
> >
> >
> >
> >    if (SmbiosTable == NULL) {
> >
> > @@ -149,7 +150,7 @@ SmbiosPrintEPSInfo (
> >
> >
> >    if (Option >= SHOW_NORMAL) {
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN),
> > gShellDebug1HiiHandle);
> >
> > -    MemToString (Anchor, SmbiosTable->AnchorString, 4);
> >
> > +    MemToString (Anchor, SmbiosTable->AnchorString,
> > SMBIOS_ANCHOR_STRING_LENGTH);
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> > Anchor);
> >
> >      ShellPrintHiiEx (
> >
> >        -1,
> >
> > @@ -220,7 +221,7 @@ Smbios64BitPrintEPSInfo (
> >    IN  UINT8                         Option
> >
> >    )
> >
> >  {
> >
> > -  UINT8  Anchor[5];
> >
> > +  UINT8  Anchor[SMBIOS_3_0_ANCHOR_STRING_LENGTH + 1]; ///<
> > Including terminating NULL character
> >
> >
> >
> >    if (SmbiosTable == NULL) {
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL),
> > gShellDebug1HiiHandle);
> >
> > @@ -234,7 +235,7 @@ Smbios64BitPrintEPSInfo (
> >    if (Option >= SHOW_NORMAL) {
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN),
> > gShellDebug1HiiHandle);
> >
> >
> >
> > -    MemToString (Anchor, SmbiosTable->AnchorString, 5);
> >
> > +    MemToString (Anchor, SmbiosTable->AnchorString,
> > SMBIOS_3_0_ANCHOR_STRING_LENGTH);
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> > Anchor);
> >
> >
> >
> >      ShellPrintHiiEx (
> >
> > diff --git
> >
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> >
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> > index e9360beb23..7e7eef3fd8 100644
> > ---
> >
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> > +++
> >
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
> > @@ -3,6 +3,7 @@
> >
> >
> >    (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
> >
> >    Copyright (c) 2005 - 2018, Intel Corporation. All rights
reserved.<BR>
> >
> > +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
> >
> >    SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> >  **/
> >
> > @@ -263,7 +264,7 @@ SMBiosView (
> >      return EFI_BAD_BUFFER_SIZE;
> >
> >    }
> >
> >
> >
> > -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) {
> >
> > +  if (CompareMem (SMBiosTable->AnchorString,
> SMBIOS_ANCHOR_STRING,
> > SMBIOS_ANCHOR_STRING_LENGTH) == 0) {
> >
> >      //
> >
> >      // Have got SMBIOS table
> >
> >      //
> >
> > @@ -441,7 +442,7 @@ SMBios64View (
> >      return EFI_BAD_BUFFER_SIZE;
> >
> >    }
> >
> >
> >
> > -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) == 0) {
> >
> > +  if (CompareMem (SMBiosTable->AnchorString,
> > SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH)
> > == 0) {
> >
> >      //
> >
> >      // Have got SMBIOS table
> >
> >      //
> >
> > @@ -612,7 +613,7 @@ InitSmbiosTableStatistics (
> >      return EFI_NOT_FOUND;
> >
> >    }
> >
> >
> >
> > -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) {
> >
> > +  if (CompareMem (SMBiosTable->AnchorString,
> SMBIOS_ANCHOR_STRING,
> > SMBIOS_ANCHOR_STRING_LENGTH) != 0) {
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE),
> gShellDebug1HiiHandle);
> >
> >      return EFI_INVALID_PARAMETER;
> >
> >    }
> >
> > @@ -753,7 +754,7 @@ InitSmbios64BitTableStatistics (
> >      return EFI_NOT_FOUND;
> >
> >    }
> >
> >
> >
> > -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) != 0) {
> >
> > +  if (CompareMem (SMBiosTable->AnchorString,
> > SMBIOS_3_0_ANCHOR_STRING,
> > SMBIOS_3_0_ANCHOR_STRING_LENGTH) != 0) {
> >
> >      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE),
> gShellDebug1HiiHandle);
> >
> >      return EFI_INVALID_PARAMETER;
> >
> >    }
> >
> > --
> > 2.39.2 (Apple Git-144)
> 
> 
> 
> 
> 
> 
> 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
  2023-05-06  6:55     ` 回复: [edk2-devel] " gaoliming
@ 2023-05-06 10:00       ` Giri Mudusuru
  0 siblings, 0 replies; 6+ messages in thread
From: Giri Mudusuru @ 2023-05-06 10:00 UTC (permalink / raw)
  To: gaoliming
  Cc: devel, Michael D Kinney, Zhiguang Liu, Andrew Fish, Giri Mudusuru

Thanks Liming. Was not aware that ///< cannot be used while declaring variables.

Will send V2 for 2nd patch.

Thanks,
-Giri

> On May 6, 2023, at 12:25 PM, gaoliming <gaoliming@byosoft.com.cn> wrote:
> 
> Giri:
>  I create PR https://github.com/tianocore/edk2/pull/4350 to merge this
> patch. But, Open CI reports the below issue. Please help fix them. 
> 
> ERROR - 
> ERROR - EFI coding style error
> ERROR - *Error code: 9004
> ERROR - *For comment line with '///< ... text ...' format, if it is used, it
> should be after the code section
> ERROR - *file:
> //__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
> andsLib/SmbiosView/PrintInfo.c
> ERROR - *Line number: 139
> ERROR - *
> ERROR - 
> ERROR - EFI coding style error
> ERROR - *Error code: 9004
> ERROR - *For comment line with '///< ... text ...' format, if it is used, it
> should be after the code section
> ERROR - *file:
> //__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
> andsLib/SmbiosView/PrintInfo.c
> ERROR - *Line number: 224
> ERROR - *
> 
> Thanks
> Liming
>> -----邮件原件-----
>> 发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 gaoliming via
>> groups.io
>> 发送时间: 2023年5月4日 15:57
>> 收件人: 'Giri Mudusuru' <girim@apple.com>; devel@edk2.groups.io
>> 抄送: 'Michael D Kinney' <michael.d.kinney@intel.com>; 'Zhiguang Liu'
>> <zhiguang.liu@intel.com>; 'Andrew Fish' <afish@apple.com>
>> 主题: [edk2-devel] 回复: [PATCH 2/2]
>> ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
>> 
>> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
>> 
>>> -----邮件原件-----
>>> 发件人: Giri Mudusuru <girim@apple.com>
>>> 发送时间: 2023年4月29日 2:53
>>> 收件人: devel@edk2.groups.io
>>> 抄送: Giri Mudusuru <girim@apple.com>; Michael D Kinney
>>> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
>>> Zhiguang Liu <zhiguang.liu@intel.com>; Andrew Fish <afish@apple.com>
>>> 主题: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace
>>> hardcoded SMBIOS strings.
>>> 
>>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805
>>> 
>>> Replace hardcoded SMBIOS Anchor string and size with defines.
>>> 
>>> Fix buffer overflow as described below.
>>> 
>>> Smbios64BitPrintEPSInfo () is coded like:
>>> UINT8  Anchor[5];
>>> 
>>> MemToString (Anchor, SmbiosTable->AnchorString, 5);
>>> 
>>> But the definition of MemToString()
>>>  Copy Length of Src buffer to Dest buffer,
>>>  add a NULL termination to Dest buffer.
>>> 
>>> So Anchor needs to be +1 the size of the SMBIOS Anchor string `_SM3_`.
>>> 
>>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>>> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>>> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
>>> Cc: Andrew Fish <afish@apple.com>
>>> Signed-off-by: Giri Mudusuru <girim@apple.com>
>>> ---
>>> .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c    | 9
>> +++++----
>>> .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c   | 9
>>> +++++----
>>> 2 files changed, 10 insertions(+), 8 deletions(-)
>>> 
>>> diff --git
>>> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
>>> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
>>> index 1811cf0c44..dd190b006f 100644
>>> ---
>> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
>>> +++
>>> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
>>> @@ -5,6 +5,7 @@
>>>   Copyright (c) 1985 - 2022, American Megatrends International LLC.<BR>
>>> 
>>>   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
>>> 
>>>   (C) Copyright 2015-2019 Hewlett Packard Enterprise Development
>>> LP<BR>
>>> 
>>> +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
>>> 
>>>   SPDX-License-Identifier: BSD-2-Clause-Patent
>>> 
>>> 
>>> 
>>> **/
>>> 
>>> @@ -135,7 +136,7 @@ SmbiosPrintEPSInfo (
>>>   IN  UINT8                     Option
>>> 
>>>   )
>>> 
>>> {
>>> 
>>> -  UINT8  Anchor[5];
>>> 
>>> +  UINT8  Anchor[SMBIOS_ANCHOR_STRING_LENGTH + 1]; ///<
>> Including
>>> terminating NULL character
>>> 
>>>   UINT8  InAnchor[6];
>>> 
>>> 
>>> 
>>>   if (SmbiosTable == NULL) {
>>> 
>>> @@ -149,7 +150,7 @@ SmbiosPrintEPSInfo (
>>> 
>>> 
>>>   if (Option >= SHOW_NORMAL) {
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN),
>>> gShellDebug1HiiHandle);
>>> 
>>> -    MemToString (Anchor, SmbiosTable->AnchorString, 4);
>>> 
>>> +    MemToString (Anchor, SmbiosTable->AnchorString,
>>> SMBIOS_ANCHOR_STRING_LENGTH);
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
>>> Anchor);
>>> 
>>>     ShellPrintHiiEx (
>>> 
>>>       -1,
>>> 
>>> @@ -220,7 +221,7 @@ Smbios64BitPrintEPSInfo (
>>>   IN  UINT8                         Option
>>> 
>>>   )
>>> 
>>> {
>>> 
>>> -  UINT8  Anchor[5];
>>> 
>>> +  UINT8  Anchor[SMBIOS_3_0_ANCHOR_STRING_LENGTH + 1]; ///<
>>> Including terminating NULL character
>>> 
>>> 
>>> 
>>>   if (SmbiosTable == NULL) {
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL),
>>> gShellDebug1HiiHandle);
>>> 
>>> @@ -234,7 +235,7 @@ Smbios64BitPrintEPSInfo (
>>>   if (Option >= SHOW_NORMAL) {
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN),
>>> gShellDebug1HiiHandle);
>>> 
>>> 
>>> 
>>> -    MemToString (Anchor, SmbiosTable->AnchorString, 5);
>>> 
>>> +    MemToString (Anchor, SmbiosTable->AnchorString,
>>> SMBIOS_3_0_ANCHOR_STRING_LENGTH);
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
>>> Anchor);
>>> 
>>> 
>>> 
>>>     ShellPrintHiiEx (
>>> 
>>> diff --git
>>> 
>> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
>>> 
>> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
>>> index e9360beb23..7e7eef3fd8 100644
>>> ---
>>> 
>> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
>>> +++
>>> 
>> b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c
>>> @@ -3,6 +3,7 @@
>>> 
>>> 
>>>   (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
>>> 
>>>   Copyright (c) 2005 - 2018, Intel Corporation. All rights
> reserved.<BR>
>>> 
>>> +  Copyright (c) 2023 Apple Inc. All rights reserved.<BR>
>>> 
>>>   SPDX-License-Identifier: BSD-2-Clause-Patent
>>> 
>>> 
>>> 
>>> **/
>>> 
>>> @@ -263,7 +264,7 @@ SMBiosView (
>>>     return EFI_BAD_BUFFER_SIZE;
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) == 0) {
>>> 
>>> +  if (CompareMem (SMBiosTable->AnchorString,
>> SMBIOS_ANCHOR_STRING,
>>> SMBIOS_ANCHOR_STRING_LENGTH) == 0) {
>>> 
>>>     //
>>> 
>>>     // Have got SMBIOS table
>>> 
>>>     //
>>> 
>>> @@ -441,7 +442,7 @@ SMBios64View (
>>>     return EFI_BAD_BUFFER_SIZE;
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) == 0) {
>>> 
>>> +  if (CompareMem (SMBiosTable->AnchorString,
>>> SMBIOS_3_0_ANCHOR_STRING, SMBIOS_3_0_ANCHOR_STRING_LENGTH)
>>> == 0) {
>>> 
>>>     //
>>> 
>>>     // Have got SMBIOS table
>>> 
>>>     //
>>> 
>>> @@ -612,7 +613,7 @@ InitSmbiosTableStatistics (
>>>     return EFI_NOT_FOUND;
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> -  if (CompareMem (SMBiosTable->AnchorString, "_SM_", 4) != 0) {
>>> 
>>> +  if (CompareMem (SMBiosTable->AnchorString,
>> SMBIOS_ANCHOR_STRING,
>>> SMBIOS_ANCHOR_STRING_LENGTH) != 0) {
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE),
>> gShellDebug1HiiHandle);
>>> 
>>>     return EFI_INVALID_PARAMETER;
>>> 
>>>   }
>>> 
>>> @@ -753,7 +754,7 @@ InitSmbios64BitTableStatistics (
>>>     return EFI_NOT_FOUND;
>>> 
>>>   }
>>> 
>>> 
>>> 
>>> -  if (CompareMem (SMBiosTable->AnchorString, "_SM3_", 5) != 0) {
>>> 
>>> +  if (CompareMem (SMBiosTable->AnchorString,
>>> SMBIOS_3_0_ANCHOR_STRING,
>>> SMBIOS_3_0_ANCHOR_STRING_LENGTH) != 0) {
>>> 
>>>     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
>>> (STR_SMBIOSVIEW_SMBIOSVIEW_SMBIOS_TABLE),
>> gShellDebug1HiiHandle);
>>> 
>>>     return EFI_INVALID_PARAMETER;
>>> 
>>>   }
>>> 
>>> --
>>> 2.39.2 (Apple Git-144)
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-06 10:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-28 18:52 [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines Giri Mudusuru
2023-04-28 18:52 ` [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings Giri Mudusuru
2023-05-04  7:57   ` 回复: " gaoliming
     [not found]   ` <175BE1BE3E9B8CC1.28444@groups.io>
2023-05-06  6:55     ` 回复: [edk2-devel] " gaoliming
2023-05-06 10:00       ` [edk2-devel] " Giri Mudusuru
2023-05-04  7:53 ` 回复: [PATCH 1/2] MdePkg/IndustryStandard: Add SMBIOS anchor string & length defines gaoliming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox