diff options
author | Hao Wu <hao.a.wu@intel.com> | 2017-02-14 10:11:58 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2017-02-15 15:39:44 +0800 |
commit | cb8674999c6bf94cdb3be18df3746131aac6386b (patch) | |
tree | 64046974cfd64bca2d1eacb43cea82211bd38425 /MdePkg/Library | |
parent | 5e9e151c2061cc10e5aa9f41c6f1d7d1b865954e (diff) | |
download | edk2-platforms-cb8674999c6bf94cdb3be18df3746131aac6386b.tar.xz |
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 <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'MdePkg/Library')
-rw-r--r-- | MdePkg/Library/BaseLib/SafeString.c | 8 |
1 files changed, 4 insertions, 4 deletions
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;
}
|