From cb8674999c6bf94cdb3be18df3746131aac6386b Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Tue, 14 Feb 2017 10:11:58 +0800 Subject: MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0 https://bugzilla.tianocore.org/show_bug.cgi?id=378 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Jiewen Yao --- MdePkg/Library/BaseLib/SafeString.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'MdePkg/Library') diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c index 315059e5dc..79c79e0ec2 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; } -- cgit v1.2.3