public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0
@ 2017-02-14  2:42 Hao Wu
  2017-02-15  5:58 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Hao Wu @ 2017-02-14  2:42 UTC (permalink / raw)
  To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Liming Gao, Michael Kinney

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

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdePkg/Library/BaseLib/SafeString.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
index 315059e..79c79e0 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -128,9 +128,9 @@ StrnLenS (
   ASSERT (((UINTN) String & BIT0) == 0);
 
   //
-  // If String is a null pointer, then the StrnLenS function returns zero.
+  // If String is a null pointer or MaxSize is 0, then the StrnLenS function returns zero.
   //
-  if (String == NULL) {
+  if ((String == NULL) || (MaxSize == 0)) {
     return 0;
   }
 
@@ -1097,9 +1097,9 @@ AsciiStrnLenS (
   UINTN                             Length;
 
   //
-  // If String is a null pointer, then the AsciiStrnLenS function returns zero.
+  // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS function returns zero.
   //
-  if (String == NULL) {
+  if ((String == NULL) || (MaxSize == 0)) {
     return 0;
   }
 
-- 
1.9.5.msysgit.0



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

* Re: [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0
  2017-02-14  2:42 [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0 Hao Wu
@ 2017-02-15  5:58 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2017-02-15  5:58 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Gao, Liming, Kinney, Michael D

Reviewed-by: jiewen.yao@intel.com

> -----Original Message-----
> From: Wu, Hao A
> Sent: Monday, February 13, 2017 6:43 PM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Gao, Liming <liming.gao@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle
> MaxSize = 0
> 
> https://bugzilla.tianocore.org/show_bug.cgi?id=378
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
>  MdePkg/Library/BaseLib/SafeString.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseLib/SafeString.c
> b/MdePkg/Library/BaseLib/SafeString.c
> index 315059e..79c79e0 100644
> --- a/MdePkg/Library/BaseLib/SafeString.c
> +++ b/MdePkg/Library/BaseLib/SafeString.c
> @@ -128,9 +128,9 @@ StrnLenS (
>    ASSERT (((UINTN) String & BIT0) == 0);
> 
>    //
> -  // If String is a null pointer, then the StrnLenS function returns zero.
> +  // If String is a null pointer or MaxSize is 0, then the StrnLenS function returns
> zero.
>    //
> -  if (String == NULL) {
> +  if ((String == NULL) || (MaxSize == 0)) {
>      return 0;
>    }
> 
> @@ -1097,9 +1097,9 @@ AsciiStrnLenS (
>    UINTN                             Length;
> 
>    //
> -  // If String is a null pointer, then the AsciiStrnLenS function returns zero.
> +  // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS function
> returns zero.
>    //
> -  if (String == NULL) {
> +  if ((String == NULL) || (MaxSize == 0)) {
>      return 0;
>    }
> 
> --
> 1.9.5.msysgit.0



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

end of thread, other threads:[~2017-02-15  5:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14  2:42 [PATCH] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0 Hao Wu
2017-02-15  5:58 ` Yao, Jiewen

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