[edk2-devel] [PATCH] ShellPkg: smbiosview - print field values as unsigned integers

Rebecca Cran posted 1 patch 4 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/20200424225555.187831-1-rebecca@bsdio.com
.../Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c   | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[edk2-devel] [PATCH] ShellPkg: smbiosview - print field values as unsigned integers
Posted by Rebecca Cran 4 years ago
This prevents overflow when printing DWORD fields such as the type 17
tables's extended DIMM size.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
 .../Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index a75caff3de..be8b7c0a97 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -49,7 +49,7 @@
 #define PRINT_STRUCT_VALUE(pStruct, type, element) \
   do { \
     ShellPrintEx(-1,-1,L"%a",#element); \
-    ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \
+    ShellPrintEx(-1,-1,L": %u\n", (pStruct->type->element)); \
   } while (0);
 
 #define PRINT_STRUCT_VALUE_H(pStruct, type, element) \
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58123): https://edk2.groups.io/g/devel/message/58123
Mute This Topic: https://groups.io/mt/73253250/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] ShellPkg: smbiosview - print field values as unsigned integers
Posted by Philippe Mathieu-Daudé 4 years ago
Hi Rebecca,

On 4/25/20 12:55 AM, Rebecca Cran wrote:
> This prevents overflow when printing DWORD fields such as the type 17
> tables's extended DIMM size.

Similar issue with type 14:

         ShellPrintEx(-1,-1,L"ItemType %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemType);

         ShellPrintEx(-1,-1,L"ItemHandle %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemHandle);


Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>

> 
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
> ---
>   .../Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c   | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> index a75caff3de..be8b7c0a97 100644
> --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> @@ -49,7 +49,7 @@
>   #define PRINT_STRUCT_VALUE(pStruct, type, element) \
>     do { \
>       ShellPrintEx(-1,-1,L"%a",#element); \
> -    ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \
> +    ShellPrintEx(-1,-1,L": %u\n", (pStruct->type->element)); \
>     } while (0);
>   
>   #define PRINT_STRUCT_VALUE_H(pStruct, type, element) \
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58163): https://edk2.groups.io/g/devel/message/58163
Mute This Topic: https://groups.io/mt/73253250/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-