Re: [edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-20 Thread Laszlo Ersek
On 05/20/20 05:11, Michael D Kinney wrote:
> From: Vitaly Cheptsov 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054
> 
> Runtime checks returned via status return code should not work as
> assertions to permit parsing not trusted data with SafeString
> interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.
> 
> Cc: Andrew Fish 
> Cc: Ard Biesheuvel 
> Cc: Bret Barkelew 
> Cc: Brian J. Johnson 
> Cc: Chasel Chiu 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Marvin H?user 
> Cc: Michael D Kinney 
> Cc: Vincent Zimmer 
> Cc: Zhichao Gao 
> Cc: Jiewen Yao 
> Signed-off-by: Vitaly Cheptsov 
> ---
>  MdePkg/Include/Library/BaseLib.h| 111 ---
>  MdePkg/Library/BaseLib/SafeString.c | 115 +---
>  2 files changed, 3 insertions(+), 223 deletions(-)

Reviewed-by: Laszlo Ersek 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59986): https://edk2.groups.io/g/devel/message/59986
Mute This Topic: https://groups.io/mt/74342113/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [EXTERNAL] Re: [edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-20 Thread Bret Barkelew via groups.io
Reviewed-by: Bret Barkelew 

- Bret

From: Vitaly Cheptsov via groups.io<mailto:vit9696=protonmail@groups.io>
Sent: Tuesday, May 19, 2020 10:56 PM
To: Kinney, Michael D<mailto:michael.d.kin...@intel.com>; Laszlo 
Ersek<mailto:ler...@redhat.com>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Andrew 
Fish<mailto:af...@apple.com>; Ard Biesheuvel<mailto:ard.biesheu...@linaro.org>; 
Bret Barkelew<mailto:bret.barke...@microsoft.com>; Brian J . 
Johnson<mailto:brian.john...@hpe.com>; Chasel 
Chiu<mailto:chasel.c...@intel.com>; Jordan 
Justen<mailto:jordan.l.jus...@intel.com>; Leif 
Lindholm<mailto:l...@nuviainc.com>; liming.gao<mailto:liming@intel.com>; 
Marvin H?user<mailto:mhaeu...@outlook.de>; Zimmer, 
Vincent<mailto:vincent.zim...@intel.com>; Zhichao 
Gao<mailto:zhichao....@intel.com>; Yao, Jiewen<mailto:jiewen@intel.com>
Subject: [EXTERNAL] Re: [edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString 
performing assertions on runtime checks

Mike,

Looks perfect to me. For everyone: the only change from V7 is an addition of 
DEBUG_VERBOSE message, which can indeed be useful.

Best wishes,
Vitaly

> 20 мая 2020 г., в 06:01, Michael D Kinney  
> написал(а):
>
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054
>
> Runtime checks returned via status return code should not work as
> assertions to permit parsing not trusted data with SafeString
> interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.
>
> Cc: Andrew Fish 
> Cc: Ard Biesheuvel 
> Cc: Bret Barkelew 
> Cc: Brian J. Johnson 
> Cc: Chasel Chiu 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Marvin H?user 
> Cc: Michael D Kinney 
> Cc: Vincent Zimmer 
> Cc: Zhichao Gao 
> Cc: Jiewen Yao 
> Signed-off-by: Vitaly Cheptsov 
> ---
> MdePkg/Include/Library/BaseLib.h| 111 ---
> MdePkg/Library/BaseLib/SafeString.c | 115 +---
> 2 files changed, 3 insertions(+), 223 deletions(-)
>
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index b0bbe8cef8..8e7b87cbda 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -216,7 +216,6 @@ StrnSizeS (
>
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
>
>   If an error is returned, then the Destination is unmodified.
>
> @@ -252,7 +251,6 @@ StrCpyS (
>
>   If Length > 0 and Destination is not aligned on a 16-bit boundary, then 
> ASSERT().
>   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
>
>   If an error is returned, then the Destination is unmodified.
>
> @@ -290,7 +288,6 @@ StrnCpyS (
>
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
>
>   If an error is returned, then the Destination is unmodified.
>
> @@ -330,7 +327,6 @@ StrCatS (
>
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
>
>   If an error is returned, then the Destination is unmodified.
>
> @@ -377,12 +373,7 @@ StrnCatS (
>   be ignored. Then, the function stops at the first character that is a not a
>   valid decimal character or a Null-terminator, whichever one comes first.
>
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
>
>   If String has no valid decimal digits in the above format, then 0 is stored
>   at the location pointed to by Data.
> @@ -433,12 +424,7 @@ StrDecimalToUintnS (
>   be ignored. Then, the function stops at the first character that is a not a
>   valid decimal character or a Null-terminator, whichever one comes first.
>
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
&

Re: [edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-20 Thread Liming Gao
Reviewed-by: Liming Gao 

> -Original Message-
> From: Kinney, Michael D 
> Sent: Wednesday, May 20, 2020 11:01 AM
> To: devel@edk2.groups.io
> Cc: Andrew Fish ; Ard Biesheuvel 
> ; Bret Barkelew ;
> Brian J . Johnson ; Chiu, Chasel 
> ; Justen, Jordan L ;
> Laszlo Ersek ; Leif Lindholm ; Gao, 
> Liming ; Marvin H?user
> ; Zimmer, Vincent ; Gao, 
> Zhichao ; Yao, Jiewen
> ; Vitaly Cheptsov 
> Subject: [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on 
> runtime checks
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054
> 
> Runtime checks returned via status return code should not work as
> assertions to permit parsing not trusted data with SafeString
> interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.
> 
> Cc: Andrew Fish 
> Cc: Ard Biesheuvel 
> Cc: Bret Barkelew 
> Cc: Brian J. Johnson 
> Cc: Chasel Chiu 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Marvin H?user 
> Cc: Michael D Kinney 
> Cc: Vincent Zimmer 
> Cc: Zhichao Gao 
> Cc: Jiewen Yao 
> Signed-off-by: Vitaly Cheptsov 
> ---
>  MdePkg/Include/Library/BaseLib.h| 111 ---
>  MdePkg/Library/BaseLib/SafeString.c | 115 +---
>  2 files changed, 3 insertions(+), 223 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index b0bbe8cef8..8e7b87cbda 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -216,7 +216,6 @@ StrnSizeS (
> 
>If Destination is not aligned on a 16-bit boundary, then ASSERT().
>If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>If an error is returned, then the Destination is unmodified.
> 
> @@ -252,7 +251,6 @@ StrCpyS (
> 
>If Length > 0 and Destination is not aligned on a 16-bit boundary, then 
> ASSERT().
>If Length > 0 and Source is not aligned on a 16-bit boundary, then 
> ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>If an error is returned, then the Destination is unmodified.
> 
> @@ -290,7 +288,6 @@ StrnCpyS (
> 
>If Destination is not aligned on a 16-bit boundary, then ASSERT().
>If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>If an error is returned, then the Destination is unmodified.
> 
> @@ -330,7 +327,6 @@ StrCatS (
> 
>If Destination is not aligned on a 16-bit boundary, then ASSERT().
>If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>If an error is returned, then the Destination is unmodified.
> 
> @@ -377,12 +373,7 @@ StrnCatS (
>be ignored. Then, the function stops at the first character that is a not a
>valid decimal character or a Null-terminator, whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>If String has no valid decimal digits in the above format, then 0 is stored
>at the location pointed to by Data.
> @@ -433,12 +424,7 @@ StrDecimalToUintnS (
>be ignored. Then, the function stops at the first character that is a not a
>valid decimal character or a Null-terminator, whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>If String has no valid decimal digits in the above format, then 0 is stored
>at the location pointed to by Data.
> @@ -494,12 +480,7 @@ StrDecimalToUint64S (
>the first character that is a not a valid hexadecimal character or NULL,
>whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>If String has no valid hexadecimal digits in the above format, then 0 is
>stored at the location pointed to by Data.
> @@ -555,12 +536,7 @@ StrHexToUintnS (
>the first character that is a not a valid hexadecimal character or NULL,
>whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>If String 

Re: [edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-19 Thread Vitaly Cheptsov via groups.io
Mike,

Looks perfect to me. For everyone: the only change from V7 is an addition of 
DEBUG_VERBOSE message, which can indeed be useful.

Best wishes,
Vitaly

> 20 мая 2020 г., в 06:01, Michael D Kinney  
> написал(а):
> 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054
> 
> Runtime checks returned via status return code should not work as
> assertions to permit parsing not trusted data with SafeString
> interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.
> 
> Cc: Andrew Fish 
> Cc: Ard Biesheuvel 
> Cc: Bret Barkelew 
> Cc: Brian J. Johnson 
> Cc: Chasel Chiu 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Marvin H?user 
> Cc: Michael D Kinney 
> Cc: Vincent Zimmer 
> Cc: Zhichao Gao 
> Cc: Jiewen Yao 
> Signed-off-by: Vitaly Cheptsov 
> ---
> MdePkg/Include/Library/BaseLib.h| 111 ---
> MdePkg/Library/BaseLib/SafeString.c | 115 +---
> 2 files changed, 3 insertions(+), 223 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index b0bbe8cef8..8e7b87cbda 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -216,7 +216,6 @@ StrnSizeS (
> 
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>   If an error is returned, then the Destination is unmodified.
> 
> @@ -252,7 +251,6 @@ StrCpyS (
> 
>   If Length > 0 and Destination is not aligned on a 16-bit boundary, then 
> ASSERT().
>   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>   If an error is returned, then the Destination is unmodified.
> 
> @@ -290,7 +288,6 @@ StrnCpyS (
> 
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>   If an error is returned, then the Destination is unmodified.
> 
> @@ -330,7 +327,6 @@ StrCatS (
> 
>   If Destination is not aligned on a 16-bit boundary, then ASSERT().
>   If Source is not aligned on a 16-bit boundary, then ASSERT().
> -  If an error would be returned, then the function will also ASSERT().
> 
>   If an error is returned, then the Destination is unmodified.
> 
> @@ -377,12 +373,7 @@ StrnCatS (
>   be ignored. Then, the function stops at the first character that is a not a
>   valid decimal character or a Null-terminator, whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>   If String has no valid decimal digits in the above format, then 0 is stored
>   at the location pointed to by Data.
> @@ -433,12 +424,7 @@ StrDecimalToUintnS (
>   be ignored. Then, the function stops at the first character that is a not a
>   valid decimal character or a Null-terminator, whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>   If String has no valid decimal digits in the above format, then 0 is stored
>   at the location pointed to by Data.
> @@ -494,12 +480,7 @@ StrDecimalToUint64S (
>   the first character that is a not a valid hexadecimal character or NULL,
>   whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>   If String has no valid hexadecimal digits in the above format, then 0 is
>   stored at the location pointed to by Data.
> @@ -555,12 +536,7 @@ StrHexToUintnS (
>   the first character that is a not a valid hexadecimal character or NULL,
>   whichever one comes first.
> 
> -  If String is NULL, then ASSERT().
> -  If Data is NULL, then ASSERT().
>   If String is not aligned in a 16-bit boundary, then ASSERT().
> -  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
> -  PcdMaximumUnicodeStringLength Unicode characters, not including the
> -  Null-terminator, then ASSERT().
> 
>   If String has no valid hexadecimal digits in the above 

[edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-19 Thread Michael D Kinney
From: Vitaly Cheptsov 

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

Runtime checks returned via status return code should not work as
assertions to permit parsing not trusted data with SafeString
interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.

Cc: Andrew Fish 
Cc: Ard Biesheuvel 
Cc: Bret Barkelew 
Cc: Brian J. Johnson 
Cc: Chasel Chiu 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Marvin H?user 
Cc: Michael D Kinney 
Cc: Vincent Zimmer 
Cc: Zhichao Gao 
Cc: Jiewen Yao 
Signed-off-by: Vitaly Cheptsov 
---
 MdePkg/Include/Library/BaseLib.h| 111 ---
 MdePkg/Library/BaseLib/SafeString.c | 115 +---
 2 files changed, 3 insertions(+), 223 deletions(-)

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index b0bbe8cef8..8e7b87cbda 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -216,7 +216,6 @@ StrnSizeS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -252,7 +251,6 @@ StrCpyS (
 
   If Length > 0 and Destination is not aligned on a 16-bit boundary, then 
ASSERT().
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -290,7 +288,6 @@ StrnCpyS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -330,7 +327,6 @@ StrCatS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -377,12 +373,7 @@ StrnCatS (
   be ignored. Then, the function stops at the first character that is a not a
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -433,12 +424,7 @@ StrDecimalToUintnS (
   be ignored. Then, the function stops at the first character that is a not a
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -494,12 +480,7 @@ StrDecimalToUint64S (
   the first character that is a not a valid hexadecimal character or NULL,
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -555,12 +536,7 @@ StrHexToUintnS (
   the first character that is a not a valid hexadecimal character or NULL,
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -649,8 +625,6 @@ AsciiStrnSizeS (
 
   This function is similar as strcpy_s defined in C11.
 
-  If an error would be returned, then the function will also ASSERT().
-
   If an error is returned, then the Destination is unmodified.
 
   @param  Destination  A pointer to a Null-terminated Ascii 

[edk2-devel] [Patch v8 1/2] MdePkg: Fix SafeString performing assertions on runtime checks

2020-05-19 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2054

Runtime checks returned via status return code should not work as
assertions to permit parsing not trusted data with SafeString
interfaces.  Replace ASSERT() with a DEBUG_VERBOSE message.

Cc: Andrew Fish 
Cc: Ard Biesheuvel 
Cc: Bret Barkelew 
Cc: Brian J. Johnson 
Cc: Chasel Chiu 
Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Marvin H?user 
Cc: Michael D Kinney 
Cc: Vincent Zimmer 
Cc: Zhichao Gao 
Cc: Jiewen Yao 
Signed-off-by: Vitaly Cheptsov 
---
 MdePkg/Include/Library/BaseLib.h| 111 ---
 MdePkg/Library/BaseLib/SafeString.c | 115 +---
 2 files changed, 3 insertions(+), 223 deletions(-)

diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h
index b0bbe8cef8..8e7b87cbda 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -216,7 +216,6 @@ StrnSizeS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -252,7 +251,6 @@ StrCpyS (
 
   If Length > 0 and Destination is not aligned on a 16-bit boundary, then 
ASSERT().
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -290,7 +288,6 @@ StrnCpyS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -330,7 +327,6 @@ StrCatS (
 
   If Destination is not aligned on a 16-bit boundary, then ASSERT().
   If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If an error would be returned, then the function will also ASSERT().
 
   If an error is returned, then the Destination is unmodified.
 
@@ -377,12 +373,7 @@ StrnCatS (
   be ignored. Then, the function stops at the first character that is a not a
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -433,12 +424,7 @@ StrDecimalToUintnS (
   be ignored. Then, the function stops at the first character that is a not a
   valid decimal character or a Null-terminator, whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid decimal digits in the above format, then 0 is stored
   at the location pointed to by Data.
@@ -494,12 +480,7 @@ StrDecimalToUint64S (
   the first character that is a not a valid hexadecimal character or NULL,
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -555,12 +536,7 @@ StrHexToUintnS (
   the first character that is a not a valid hexadecimal character or NULL,
   whichever one comes first.
 
-  If String is NULL, then ASSERT().
-  If Data is NULL, then ASSERT().
   If String is not aligned in a 16-bit boundary, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
 
   If String has no valid hexadecimal digits in the above format, then 0 is
   stored at the location pointed to by Data.
@@ -649,8 +625,6 @@ AsciiStrnSizeS (
 
   This function is similar as strcpy_s defined in C11.
 
-  If an error would be returned, then the function will also ASSERT().
-
   If an error is returned, then the Destination is unmodified.
 
   @param  Destination  A pointer to a Null-terminated Ascii string.
@@ -683,8 +657,6 @@