[edk2] [PATCH v2] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0

Hao Wu posted 1 patch 7 years, 8 months ago
Failed in applying to current master (apply log)
MdePkg/Library/BaseLib/SafeString.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[edk2] [PATCH v2] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0
Posted by Hao Wu 7 years, 8 months ago
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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2] MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0
Posted by Wu, Hao A 7 years, 8 months ago
This patch has the wrong version information. Please ignore this one.

Sorry for that.

Best Regards,
Hao Wu


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Hao
> Wu
> Sent: Tuesday, February 14, 2017 10:42 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A; Kinney, Michael D; Yao, Jiewen; Gao, Liming
> Subject: [edk2] [PATCH v2] 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
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel