Reviewed-by: Ray Ni <ray...@intel.com>

> -----Original Message-----
> From: Kinney, Michael D <michael.d.kin...@intel.com>
> Sent: Sunday, March 12, 2023 4:12 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray...@intel.com>; Gao, Zhichao <zhichao....@intel.com>
> Subject: [Patch 1/1] ShellPkg/Library: Fix 32-bit truncation of pointer values
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4366
> 
> Update C and UNI files that are incorrectly using %x or %08x
> instead of %p for pointer values.  On 64-bit systems, this is
> truncating pointer values above 4GB.
> 
> In reviewing ShellPkg for this issue some unused UNI strings
> with incorrect format specifiers were removed instead of being
> fixed.
> 
> Cc: Ray Ni <ray...@intel.com>
> Cc: Zhichao Gao <zhichao....@intel.com>
> Signed-off-by: Michael D Kinney <michael.d.kin...@intel.com>
> ---
>  .../UefiHandleParsingLib.uni                  | 18 +++++------
>  .../UefiShellDebug1CommandsLib.uni            |  2 --
>  .../Library/UefiShellDriver1CommandsLib/Dh.c  |  2 +-
>  .../UefiShellDriver1CommandsLib.uni           | 31 +------------------
>  .../UefiShellLevel2CommandsLib.uni            |  3 +-
>  5 files changed, 12 insertions(+), 44 deletions(-)
> 
> diff --git a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> index aa3396cea94d..6bcb3cd9e461 100644
> --- a/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> +++ b/ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.uni
> @@ -173,7 +173,7 @@
>  #string STR_HII                   #language en-US "HII"
>  #string STR_HII_FORM_CALLBACK     #language en-US "HIICallback"
> 
> -#string STR_TXT_OUT_DUMP_HEADER   #language en-US "
> Address: %%H%X%%N Attrib %02x"
> +#string STR_TXT_OUT_DUMP_HEADER   #language en-US "
> Address: %%H%p%%N Attrib %02x"
>  #string STR_TXT_OUT_DUMP_LINE     #language en-US "\r\n  %c  mode %d:
> Col %d Row %d"
> 
>  #string STR_DRIVER_FAM_OVERRIDE   #language en-US
> "DriverFamilyOverride"
> @@ -361,7 +361,7 @@
>  #string STR_DEBUGSUPPORT_INFO     #language en-US "  Isa = %s"
>  #string STR_DEBUGSUPPORT_UNKNOWN  #language en-US "  Unknown
> (%%H%s%%N)"
> 
> -#string STR_PCIRB_DUMP_PH         #language en-US "
> ParentHandle..: %%H%x%%N\r\n"
> +#string STR_PCIRB_DUMP_PH         #language en-US "
> ParentHandle..: %%H%p%%N\r\n"
>  #string STR_PCIRB_DUMP_SEG        #language en-US "  Segment
> #.....: %%H%x%%N\r\n"
>  #string STR_PCIRB_DUMP_ATT        #language en-US "
> Attributes....: %%H%x%%N\r\n"
>  #string STR_PCIRB_DUMP_SUPPORTS   #language en-US "
> Supports......: %%H%x%%N\r\n"
> @@ -375,7 +375,7 @@
>                                                    "  Device #......: 
> %02x\r\n"
>                                                    "  Function #....: 
> %02x\r\n"
>                                                    "  ROM Size......: %lx\r\n"
> -                                                  "  ROM Location..: 
> %08x\r\n"
> +                                                  "  ROM Location..: %p\r\n"
>                                                    "  Vendor ID.....: 
> %04x\r\n"
>                                                    "  Device ID.....: 
> %04x\r\n"
>                                                    "  Class Code....: %02x 
> %02x %02x\r\n"
> @@ -388,18 +388,18 @@
>  #string STR_LI_DUMP_NAME          #language en-US "
> Name..........: %%H%s%%N\r\n"
> 
>  #string STR_LI_DUMP_MAIN          #language en-US "
> Revision......: %%H0x%08x%%N\r\n"
> -                                                  "  ParentHandle..: 
> %%H%x%%N\r\n"
> -                                                  "  SystemTable...: 
> %%H%x%%N\r\n"
> -                                                  "  DeviceHandle..: 
> %%H%x%%N\r\n"
> +                                                  "  ParentHandle..: 
> %%H%p%%N\r\n"
> +                                                  "  SystemTable...: 
> %%H%p%%N\r\n"
> +                                                  "  DeviceHandle..: 
> %%H%p%%N\r\n"
>                                                    "  FilePath......: 
> %%H%s%%N\r\n"
>                                                    "  PdbFileName...: 
> %%H%a%%N\r\n"
>                                                    "  OptionsSize...: 
> %%H%x%%N\r\n"
> -                                                  "  LoadOptions...: 
> %%H%x%%N\r\n"
> -                                                  "  ImageBase.....: 
> %%H%x%%N\r\n"
> +                                                  "  LoadOptions...: 
> %%H%p%%N\r\n"
> +                                                  "  ImageBase.....: 
> %%H%p%%N\r\n"
>                                                    "  ImageSize.....: 
> %%H%Lx%%N\r\n"
>                                                    "  CodeType......: 
> %%H%s%%N\r\n"
>                                                    "  DataType......: 
> %%H%s%%N\r\n"
> -                                                  "  Unload........: 
> %%H%x%%N"
> +                                                  "  Unload........: 
> %%H%p%%N"
> 
>  #string STR_GOP_DUMP_MAIN         #language en-US "  Max
> Mode..............: %%H0x%08x%%N\r\n"
>                                                    "  Current Mode..........: 
> %%H0x%08x%%N\r\n"
> diff --git
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.uni
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.uni
> index b1d239ed37ea..4fedc0d1493c 100644
> ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.uni
> +++
> b/ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Comman
> dsLib.uni
> @@ -103,7 +103,6 @@
> 
>  #string STR_DMEM_HEADER_ROW       #language en-US "Memory
> Address %016LX %X Bytes\r\n"
>  #string STR_DMEM_MMIO_HEADER_ROW  #language en-US "Memory
> Mapped IO Address %016LX %X Bytes\r\n"
> -#string STR_DMEM_DATA_ROW         #language en-US
> "%08X: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x
> %02x %02x %02x %02x *%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c*\r\n"
>  #string STR_DMEM_SYSTEM_TABLE     #language en-US "\r\nValid EFI
> Header at Address %016Lx\r\n"
>                                                    
> "---------------------------------------------\r\n"
>                                                    "System: Table Structure 
> size %08x
> revision %08x\r\n"
> @@ -1171,4 +1170,3 @@
>  " \r\n"
>  "  * To edit memory region starting at address 0x00000000 with size of 2
> bytes:\r\n"
>  "    fs0:\> hexedit -m 0 2\r\n"
> -
> diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> index dd9aba50d754..d17d50fe13fa 100644
> --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Dh.c
> @@ -325,7 +325,7 @@ GetProtocolInfoString (
>          Status = gBS->HandleProtocol (TheHandle,
> ProtocolGuidArray[ProtocolIndex], &Instance);
>          if (!EFI_ERROR (Status)) {
>            StrnCatGrow (&RetVal, &Size, L"(%H", 0);
> -          UnicodeSPrint (InstanceStr, sizeof (InstanceStr), L"%x", Instance);
> +          UnicodeSPrint (InstanceStr, sizeof (InstanceStr), L"%p", Instance);
>            StrnCatGrow (&RetVal, &Size, InstanceStr, 0);
>            StrnCatGrow (&RetVal, &Size, L"%N)", 0);
>          }
> diff --git
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> index fc4986c8c62f..230779a4b30d 100644
> ---
> a/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Command
> sLib.uni
> +++
> b/ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Comman
> dsLib.uni
> @@ -101,7 +101,7 @@
>  #string STR_DH_OUTPUT_GUID_HEADER #language en-US "Handle dump by
> protocol '%g'\r\n"
>  #string STR_DH_OUTPUT_NAME_HEADER #language en-US "Handle dump
> by protocol '%s'\r\n"
>  #string STR_DH_OUTPUT_SINGLE_D    #language en-US
> "%H%02x%N: %s\r\n"
> -#string STR_DH_OUTPUT_SINGLE      #language en-US
> "%H%02x%N: %x\r\n%s"
> +#string STR_DH_OUTPUT_SINGLE      #language en-US
> "%H%02x%N: %p\r\n%s"
>  #string STR_DH_OUTPUT_SFO         #language en-US
> "%s, %s, %s, %H%02x%N, %s, %s\r\n"
>  #string STR_DH_OUTPUT_DRIVER1     #language en-US "   Controller
> Name    : %H%s%N\r\n"
>  #string STR_DH_OUTPUT_DRIVER2     #language en-US "   Device
> Path        : %H%s%N\r\n"
> @@ -128,18 +128,6 @@
>  #string STR_DEV_TREE_OUTPUT       #language en-US
> "Ctrl[%H%02x%N] %s\r\n"
> 
>  #string STR_UNLOAD_CONF           #language en-US "%HUnload%N - Handle
> [%H%02x%N].  [y/n]?\r\n"
> -#string STR_UNLOAD_VERBOSE        #language en-US ""
> -"Handle [%H%02x%N] (%08x)\r\n"
> -"  Image (%08x)\r\n"
> -"    ParentHandle..: %08x\r\n"
> -"    SystemTable...: %08x\r\n"
> -"    DeviceHandle..: %08x\r\n"
> -"    FilePath......: %s\r\n"
> -"    PDBFileName...: %a\r\n"
> -"    ImageBase.....: %08x\r\n"
> -"    ImageSize.....: %Ld\r\n"
> -"    CodeType......: %s\r\n"
> -"    DataType......: %s\r\n"
> 
>  #string STR_OPENINFO_HEADER_LINE  #language en-US
> "Handle %H%02x%N (%H%0p%N)\r\n"
>  #string STR_OPENINFO_LINE         #language en-US "  Drv[%H%02x%N]
> Ctrl[%H%02x%N] Cnt(%H%02x%N) %H%s Image%N(%s)\r\n"
> @@ -734,20 +722,3 @@
>  "                             violation.\r\n"
>  "  SHELL_INVALID_PARAMETER    One of the passed in parameters was
> incorrectly\r\n"
>  "                             formatted or its value was out of bounds.\r\n"
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> -
> diff --git
> a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.uni
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.uni
> index 8ce015746f7c..0a0cd3090e0f 100644
> ---
> a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.uni
> +++
> b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Commands
> Lib.uni
> @@ -134,7 +134,7 @@
> 
>  #string STR_LOAD_NOT_IMAGE        #language en-US "Image '%s' is not an
> image.\r\n"
>  #string STR_LOAD_NOT_DRIVER       #language en-US "Image '%s' is not a
> driver.\r\n"
> -#string STR_LOAD_LOADED           #language en-US "Image '%s' loaded at %x
> - %r\r\n"
> +#string STR_LOAD_LOADED           #language en-US "Image '%s' loaded at %p
> - %r\r\n"
>  #string STR_LOAD_ERROR            #language en-US "Image '%s' error in
> StartImage: %r\r\n"
> 
>  #string STR_LS_LINE_START_ALL     #language en-US "%t %5s %1c % ,L11d  "
> @@ -1076,4 +1076,3 @@
>  "  SHELL_SECURITY_VIOLATION   This function was not performed due to a
> security\r\n"
>  "                             violation.\r\n"
>  "  SHELL_NOT_FOUND            The target file-system was not found.\r\n"
> -
> --
> 2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101050): https://edk2.groups.io/g/devel/message/101050
Mute This Topic: https://groups.io/mt/97547832/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: 
https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to