public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS
@ 2020-06-22 18:20 Jeff Brasen
  2020-06-24  1:36 ` Dandan Bi
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Brasen @ 2020-06-22 18:20 UTC (permalink / raw)
  To: devel; +Cc: liming.gao, dandan.bi, Jeff Brasen

UnicodeStrToAsciiStrS requires that the source string is shorter than
the destination buffer and will ASSERT if this is not true. Switch to
UnicodeStrnToAsciiStrS as there are cases where the source string is
longer than the buffer allocated for the device path.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
 .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index f500e20b32..d378c59dd9 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -837,7 +837,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
       ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
     }
 
-    UnicodeStrToAsciiStrS(StringPtr, ComponentNameString, ControllerNameStringSize);
+    UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
 
     //
     // Add a space in the end of the ControllerName
@@ -879,7 +879,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
         AsciiStringPtr = ComponentNameString;
       }
 
-      UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);
+      UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
       *Length += (UINT8)DevicePathStringSize;
       return EFI_SUCCESS;
     }
-- 
2.17.1


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

* Re: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS
  2020-06-22 18:20 [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS Jeff Brasen
@ 2020-06-24  1:36 ` Dandan Bi
  2020-07-17 20:46   ` Jeff Brasen
  0 siblings, 1 reply; 4+ messages in thread
From: Dandan Bi @ 2020-06-24  1:36 UTC (permalink / raw)
  To: Jeff Brasen, devel@edk2.groups.io; +Cc: Gao, Liming

Reviewed-by: Dandan Bi <dandan.bi@intel.com>



Thanks,
Dandan
> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Tuesday, June 23, 2020 2:20 AM
> To: devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>; Bi, Dandan <dandan.bi@intel.com>;
> Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to
> UnicodeStrnToAsciiStrS
> 
> UnicodeStrToAsciiStrS requires that the source string is shorter than the
> destination buffer and will ASSERT if this is not true. Switch to
> UnicodeStrnToAsciiStrS as there are cases where the source string is longer
> than the buffer allocated for the device path.
> 
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
>  .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c     | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> index f500e20b32..d378c59dd9 100644
> ---
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> +++
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> @@ -837,7 +837,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
>        ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) -
> 1;
>      }
> 
> -    UnicodeStrToAsciiStrS(StringPtr, ComponentNameString,
> ControllerNameStringSize);
> +    UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1,
> + ComponentNameString, ControllerNameStringSize,
> + &ControllerNameStringSize);
> 
>      //
>      // Add a space in the end of the ControllerName @@ -879,7 +879,7 @@
> GetDeviceInfoFromHandleAndUpdateLength (
>          AsciiStringPtr = ComponentNameString;
>        }
> 
> -      UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);
> +      UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1,
> + AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
>        *Length += (UINT8)DevicePathStringSize;
>        return EFI_SUCCESS;
>      }
> --
> 2.17.1


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

* Re: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS
  2020-06-24  1:36 ` Dandan Bi
@ 2020-07-17 20:46   ` Jeff Brasen
  2020-07-20  1:15     ` Dandan Bi
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Brasen @ 2020-07-17 20:46 UTC (permalink / raw)
  To: Bi, Dandan, devel@edk2.groups.io; +Cc: Gao, Liming

Do we need any additional review on this before it getting submitted?

-Jeff


-----Original Message-----
From: Bi, Dandan <dandan.bi@intel.com> 
Sent: Tuesday, June 23, 2020 7:36 PM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>
Subject: RE: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS

External email: Use caution opening links or attachments


Reviewed-by: Dandan Bi <dandan.bi@intel.com>



Thanks,
Dandan
> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Tuesday, June 23, 2020 2:20 AM
> To: devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>; Bi, Dandan 
> <dandan.bi@intel.com>; Jeff Brasen <jbrasen@nvidia.com>
> Subject: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to 
> UnicodeStrnToAsciiStrS
>
> UnicodeStrToAsciiStrS requires that the source string is shorter than 
> the destination buffer and will ASSERT if this is not true. Switch to 
> UnicodeStrnToAsciiStrS as there are cases where the source string is 
> longer than the buffer allocated for the device path.
>
> Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> ---
>  .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c     | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> index f500e20b32..d378c59dd9 100644
> ---
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> +++
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> b.c
> @@ -837,7 +837,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
>        ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - 
> (*Length) - 1;
>      }
>
> -    UnicodeStrToAsciiStrS(StringPtr, ComponentNameString,
> ControllerNameStringSize);
> +    UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1, 
> + ComponentNameString, ControllerNameStringSize, 
> + &ControllerNameStringSize);
>
>      //
>      // Add a space in the end of the ControllerName @@ -879,7 +879,7 
> @@ GetDeviceInfoFromHandleAndUpdateLength (
>          AsciiStringPtr = ComponentNameString;
>        }
>
> -      UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);
> +      UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1, 
> + AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
>        *Length += (UINT8)DevicePathStringSize;
>        return EFI_SUCCESS;
>      }
> --
> 2.17.1


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

* Re: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS
  2020-07-17 20:46   ` Jeff Brasen
@ 2020-07-20  1:15     ` Dandan Bi
  0 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2020-07-20  1:15 UTC (permalink / raw)
  To: Jeff Brasen, devel@edk2.groups.io; +Cc: Gao, Liming

I will submit this patch before the end of this Tuesday if there are no comments.


Thanks,
Dandan
> -----Original Message-----
> From: Jeff Brasen <jbrasen@nvidia.com>
> Sent: Saturday, July 18, 2020 4:46 AM
> To: Bi, Dandan <dandan.bi@intel.com>; devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to
> UnicodeStrnToAsciiStrS
> 
> Do we need any additional review on this before it getting submitted?
> 
> -Jeff
> 
> 
> -----Original Message-----
> From: Bi, Dandan <dandan.bi@intel.com>
> Sent: Tuesday, June 23, 2020 7:36 PM
> To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to
> UnicodeStrnToAsciiStrS
> 
> External email: Use caution opening links or attachments
> 
> 
> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
> 
> 
> 
> Thanks,
> Dandan
> > -----Original Message-----
> > From: Jeff Brasen <jbrasen@nvidia.com>
> > Sent: Tuesday, June 23, 2020 2:20 AM
> > To: devel@edk2.groups.io
> > Cc: Gao, Liming <liming.gao@intel.com>; Bi, Dandan
> > <dandan.bi@intel.com>; Jeff Brasen <jbrasen@nvidia.com>
> > Subject: [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to
> > UnicodeStrnToAsciiStrS
> >
> > UnicodeStrToAsciiStrS requires that the source string is shorter than
> > the destination buffer and will ASSERT if this is not true. Switch to
> > UnicodeStrnToAsciiStrS as there are cases where the source string is
> > longer than the buffer allocated for the device path.
> >
> > Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
> > ---
> >  .../Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c     | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> >
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> > b.c
> >
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> > b.c
> > index f500e20b32..d378c59dd9 100644
> > ---
> >
> a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> > b.c
> > +++
> >
> b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLi
> > b.c
> > @@ -837,7 +837,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
> >        ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE -
> > (*Length) - 1;
> >      }
> >
> > -    UnicodeStrToAsciiStrS(StringPtr, ComponentNameString,
> > ControllerNameStringSize);
> > +    UnicodeStrnToAsciiStrS(StringPtr, ControllerNameStringSize - 1,
> > + ComponentNameString, ControllerNameStringSize,
> > + &ControllerNameStringSize);
> >
> >      //
> >      // Add a space in the end of the ControllerName @@ -879,7 +879,7
> > @@ GetDeviceInfoFromHandleAndUpdateLength (
> >          AsciiStringPtr = ComponentNameString;
> >        }
> >
> > -      UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);
> > +      UnicodeStrnToAsciiStrS(StringPtr, DevicePathStringSize - 1,
> > + AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
> >        *Length += (UINT8)DevicePathStringSize;
> >        return EFI_SUCCESS;
> >      }
> > --
> > 2.17.1


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

end of thread, other threads:[~2020-07-20  1:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-22 18:20 [PATCH v2] MdeModulePkg/DxeCorePerformanceLib: Switch to UnicodeStrnToAsciiStrS Jeff Brasen
2020-06-24  1:36 ` Dandan Bi
2020-07-17 20:46   ` Jeff Brasen
2020-07-20  1:15     ` Dandan Bi

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