Date   

Re: Official way to build BaseTools - Edk2ToolsBuild.py?

Sean
 

I am not sure what the community wants to do with it. It was created for the CI build so it is tailored to the needs of the CI build but I have no problem with updates.

I agree with your feedback and see no reason either of those would be a problem for the CI use case.

Although not convenient for local builds it does currently output full build log to BaseTools/BaseToolsBuild/BASETOOLS_BUILD.txt.

Thanks
Sean

On 5/19/2020 8:23 PM, Rebecca Cran wrote:
I'm wondering if using BaseTools/Edk2ToolsBuild.py will become the official/standard way users are expected to build BaseTools? If so, there are a few problems that I'd like to see fixed, which I'll see if I can find some time to work on.
For example: on Linux, running it without arguments gives "ValueError: Bad VC" - because it defaults to the VS2017 toolchain.
If you break something in BaseTools and so it fails to build, it prints "Exception: Failed to build." with no further details.
I'd like to improve it so it detects being run on a non-Windows platform and tries to use GCC, Clang etc. - and perhaps also to add a '--verbose' argument that can be used to give a more specific error message when it fails.


[PATCH] IntelFsp2Pkg: Add FunctionParametePtr to FspGlobalData.

Chiu, Chasel
 

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

When FSP switching stack and calling bootloader functions,
the function parameter in stack may not be accessible easily.
We can store the function parameter pointer to FspGlobalData
and retrieve it after stack switched.

Also need to add Loader2PeiSwitchStack () to header file
as public function for platform FSP code to consume.

Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
IntelFsp2Pkg/Include/FspGlobalData.h | 12 ++++++++++--
IntelFsp2Pkg/Include/Library/FspSwitchStackLib.h | 18 +++++++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/IntelFsp2Pkg/Include/FspGlobalData.h b/IntelFsp2Pkg/Include/FspGlobalData.h
index 5bde316893..dba9b48e1a 100644
--- a/IntelFsp2Pkg/Include/FspGlobalData.h
+++ b/IntelFsp2Pkg/Include/FspGlobalData.h
@@ -52,12 +52,20 @@ typedef struct {
VOID *MemoryInitUpdPtr;
VOID *SiliconInitUpdPtr;
UINT8 ApiIdx;
- UINT8 FspMode; // 0: FSP in API mode; 1: FSP in DISPATCH mode
+ ///
+ /// 0: FSP in API mode; 1: FSP in DISPATCH mode
+ ///
+ UINT8 FspMode;
UINT8 OnSeparateStack;
UINT8 Reserved3;
UINT32 NumberOfPhases;
UINT32 PhasesExecuted;
- UINT8 Reserved4[20];
+ ///
+ /// To store function parameters pointer
+ /// so it can be retrieved after stack switched.
+ ///
+ VOID *FunctionParameterPtr;
+ UINT8 Reserved4[16];
UINT32 PerfSig;
UINT16 PerfLen;
UINT16 Reserved5;
diff --git a/IntelFsp2Pkg/Include/Library/FspSwitchStackLib.h b/IntelFsp2Pkg/Include/Library/FspSwitchStackLib.h
index 0c76e9f022..bed2a5d677 100644
--- a/IntelFsp2Pkg/Include/Library/FspSwitchStackLib.h
+++ b/IntelFsp2Pkg/Include/Library/FspSwitchStackLib.h
@@ -1,6 +1,6 @@
/** @file

- Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -36,4 +36,20 @@ Pei2LoaderSwitchStack (
VOID
);

+/**
+
+ This function is equilivant to Pei2LoaderSwitchStack () but just indicates
+ the stack after switched is FSP stack.
+
+ @return ReturnKey After switching to the saved stack,
+ this value will be saved in eax before returning.
+
+
+**/
+UINT32
+EFIAPI
+Loader2PeiSwitchStack (
+ VOID
+ );
+
#endif
--
2.13.3.windows.1


Re: [PATCH edk2-test] Maintainers: replace Supreeth with Edhaya as SCT maintainer

Eric Jin
 

-----Original Message-----
From: Ard Biesheuvel <ard.biesheuvel@arm.com>
Sent: Thursday, May 14, 2020 6:12 AM
To: devel@edk2.groups.io
Cc: Samer.El-Haj-Mahmoud@arm.com; Ard Biesheuvel
<ard.biesheuvel@arm.com>; Jin, Eric <eric.jin@intel.com>; G Edhaya
Chandran <Edhaya.Chandran@arm.com>; Andrew Fish <afish@apple.com>;
Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>;
Kinney, Michael D <michael.d.kinney@intel.com>
Subject: [PATCH edk2-test] Maintainers: replace Supreeth with Edhaya as
SCT maintainer

Supreeth Venkatesh no longer works for ARM, and left before we had the
chance of finding a successor. Edhaya is willing to take over SCT
maintainership so let's make it official.

Cc: Eric Jin <eric.jin@intel.com>
Cc: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
uefi-sct/Maintainers.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/uefi-sct/Maintainers.txt b/uefi-sct/Maintainers.txt index
59f3912e1de2..1ebf03fec65b 100644
--- a/uefi-sct/Maintainers.txt
+++ b/uefi-sct/Maintainers.txt
@@ -39,7 +39,7 @@ UEFI-SCT:
----------------

M: Eric Jin <eric.jin@intel.com>
-M: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
+M: G Edhaya Chandran <Edhaya.Chandran@arm.com>
Reviewed-by: Eric Jin <eric.jin@intel.com>


General questions on UEFI-SCT with the subject [edk2-test] can be sent to
L: edk2-list <edk2-devel@lists.01.org>
--
2.17.1


Official way to build BaseTools - Edk2ToolsBuild.py?

Rebecca Cran
 

I'm wondering if using BaseTools/Edk2ToolsBuild.py will become the official/standard way users are expected to build BaseTools? If so, there are a few problems that I'd like to see fixed, which I'll see if I can find some time to work on.


For example: on Linux, running it without arguments gives "ValueError: Bad VC" - because it defaults to the VS2017 toolchain.

If you break something in BaseTools and so it fails to build, it prints "Exception: Failed to build." with no further details.


I'd like to improve it so it detects being run on a non-Windows platform and tries to use GCC, Clang etc. - and perhaps also to add a '--verbose' argument that can be used to give a more specific error message when it fails.


--
Rebecca Cran


[Patch v8 2/2] MdePkg/Test/BaseLib: Add SAFE_STRING_CONSTRAINT_CHECK unit test

Michael D Kinney
 

Use the safe string function StrCpyS() in BaseLib to test the
SAFE_STRING_CONSTRAINT_CHECK() macro.

Cc: Andrew Fish <afish@apple.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Cc: Brian J. Johnson <brian.johnson@hpe.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Marvin H?user <mhaeuser@outlook.de>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Vincent Zimmer <vincent.zimmer@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
.../UnitTest/Library/BaseLib/Base64UnitTest.c | 85 +++++++++++++++++++
1 file changed, 85 insertions(+)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 8952f9da6c..5aced69e0d 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -290,6 +290,77 @@ RfcDecodeTest(
return UNIT_TEST_PASSED;
}

+#define SOURCE_STRING L"Hello"
+
+STATIC
+UNIT_TEST_STATUS
+EFIAPI
+SafeStringContraintCheckTest (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ RETURN_STATUS Status;
+ CHAR16 Destination[20];
+
+ //
+ // Positive test case copy source unicode string to destination
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_NOT_EFI_ERROR (Status);
+ UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+ //
+ // Positive test case with DestMax the same as Source size
+ //
+ Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_NOT_EFI_ERROR (Status);
+ UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+ //
+ // Negative test case with Destination NULL
+ //
+ Status = StrCpyS (NULL, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with Source NULL
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), NULL);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax too big
+ //
+ Status = StrCpyS (Destination, MAX_UINTN, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax 0
+ //
+ Status = StrCpyS (Destination, 0, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax smaller than Source size
+ //
+ Status = StrCpyS (Destination, 1, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+
+ //
+ // Negative test case with DestMax smaller than Source size by one character
+ //
+ Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16) - 1, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+
+ //
+ // Negative test case with DestMax smaller than Source size
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), Destination);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_ACCESS_DENIED);
+
+ return UNIT_TEST_PASSED;
+}
+
/**
Initialze the unit test framework, suite, and unit tests for the
Base64 conversion APIs of BaseLib and run the unit tests.
@@ -309,6 +380,7 @@ UnitTestingEntry (
UNIT_TEST_FRAMEWORK_HANDLE Fw;
UNIT_TEST_SUITE_HANDLE b64EncodeTests;
UNIT_TEST_SUITE_HANDLE b64DecodeTests;
+ UNIT_TEST_SUITE_HANDLE SafeStringTests;

Fw = NULL;

@@ -367,6 +439,19 @@ UnitTestingEntry (
AddTestCase (b64DecodeTests, "Incorrectly placed padding character", "Error4", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError4);
AddTestCase (b64DecodeTests, "Too small of output buffer", "Error5", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError5);

+ //
+ // Populate the safe string Unit Test Suite.
+ //
+ Status = CreateUnitTestSuite (&SafeStringTests, Fw, "Safe String", "BaseLib.SafeString", NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SafeStringTests\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ // --------------Suite-----------Description--------------Class Name----------Function--------Pre---Post-------------------Context-----------
+ AddTestCase (SafeStringTests, "SAFE_STRING_CONSTRAINT_CHECK", "SafeStringContraintCheckTest", SafeStringContraintCheckTest, NULL, NULL, NULL);
+
//
// Execute the tests.
//
--
2.21.0.windows.1


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

Michael D Kinney
 

From: Vitaly Cheptsov <vit9696@protonmail.com>

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 <afish@apple.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Cc: Brian J. Johnson <brian.johnson@hpe.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Marvin H?user <mhaeuser@outlook.de>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Vincent Zimmer <vincent.zimmer@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
---
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 @@ AsciiStrCpyS (

This function is similar as strncpy_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.
@@ -719,8 +691,6 @@ AsciiStrnCpyS (

This function is similar as strcat_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.
@@ -757,8 +727,6 @@ AsciiStrCatS (

This function is similar as strncat_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.
@@ -804,12 +772,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -859,12 +821,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -918,12 +874,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -977,12 +927,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -1533,16 +1477,8 @@ StrHexToUint64 (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1594,16 +1530,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1667,8 +1595,6 @@ StrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
If String is not aligned in a 16-bit boundary, then ASSERT().

@param String Pointer to a Null-terminated Unicode string.
@@ -1703,17 +1629,6 @@ StrToGuid (

If String is not aligned in a 16-bit boundary, then ASSERT().

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumUnicodeStringLength is not zero and Length is greater than
- PcdMaximumUnicodeStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated Unicode string.
@param Length The number of Unicode characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -1804,7 +1719,6 @@ UnicodeStrToAsciiStr (
the upper 8 bits, 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.

@@ -1851,7 +1765,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-zero value in the upper 8
bits, 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.

@@ -2415,10 +2328,6 @@ AsciiStrHexToUint64 (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -2470,10 +2379,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -2535,9 +2440,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Guid Pointer to the converted GUID.

@@ -2568,17 +2470,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and outputs Buffer containing
(Length / 2) bytes.

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumAsciiStringLength is not zero and Length is greater than
- PcdMaximumAsciiStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Length The number of ASCII characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -2659,7 +2550,6 @@ AsciiStrToUnicodeStr (
equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.

If Destination 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.

@@ -2705,7 +2595,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.

If Destination 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 Destination and DestinationLength are
unmodified.
diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
index 7dc03d2caa..3bb23ca1a1 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -14,8 +14,10 @@

#define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status) \
do { \
- ASSERT (Expression); \
if (!(Expression)) { \
+ DEBUG ((DEBUG_VERBOSE, \
+ "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed. Return %r\n", \
+ __FILE__, __LINE__, __FUNCTION__, #Expression, Status)); \
return Status; \
} \
} while (FALSE)
@@ -197,7 +199,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.

@@ -279,7 +280,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.

@@ -372,7 +372,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.

@@ -473,7 +472,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.

@@ -590,12 +588,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.
@@ -705,12 +698,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.
@@ -825,12 +813,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.
@@ -956,12 +939,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.
@@ -1091,16 +1069,8 @@ StrHexToUint64S (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1317,16 +1287,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1482,8 +1444,6 @@ StrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
If String is not aligned in a 16-bit boundary, then ASSERT().

@param String Pointer to a Null-terminated Unicode string.
@@ -1589,17 +1549,6 @@ StrToGuid (

If String is not aligned in a 16-bit boundary, then ASSERT().

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumUnicodeStringLength is not zero and Length is greater than
- PcdMaximumUnicodeStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated Unicode string.
@param Length The number of Unicode characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -1779,8 +1728,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.
@@ -1856,8 +1803,6 @@ AsciiStrCpyS (

This function is similar as strncpy_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.
@@ -1944,8 +1889,6 @@ AsciiStrnCpyS (

This function is similar as strcat_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.
@@ -2040,8 +1983,6 @@ AsciiStrCatS (

This function is similar as strncat_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.
@@ -2154,12 +2095,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -2266,12 +2201,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -2382,12 +2311,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -2509,12 +2432,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -2635,7 +2552,6 @@ AsciiStrHexToUint64S (
the upper 8 bits, 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.

@@ -2735,7 +2651,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-zero value in the upper 8
bits, 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 Destination and DestinationLength are
unmodified.
@@ -2855,7 +2770,6 @@ UnicodeStrnToAsciiStrS (
equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.

If Destination 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.

@@ -2948,7 +2862,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.

If Destination 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 Destination and DestinationLength are
unmodified.
@@ -3072,10 +2985,6 @@ AsciiStrnToUnicodeStrS (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -3291,10 +3200,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -3448,9 +3353,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Guid Pointer to the converted GUID.

@@ -3550,17 +3452,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and outputs Buffer containing
(Length / 2) bytes.

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumAsciiStringLength is not zero and Length is greater than
- PcdMaximumAsciiStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Length The number of ASCII characters to decode.
@param Buffer Pointer to the converted bytes array.
--
2.21.0.windows.1


[Patch v8 0/2] Disable safe string constraint assertions

Michael D Kinney
 

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

V8 Add DEBUG_VERBOSE message and unit test
V7 addressed review comments (only documentation changes).

Current implementation of SafeString does not let one parse untrusted
data with its interfaces as they ASSERT on failing runtime checks and
require one to effectively reimplement the function on the caller side.

All the former proposals made it clear that the attempts to introduce
a solution preserving this behavior require a lot of changes
throughout the codebase including platform code (e.g. introducing
constraint assertions and updating all DebugLib implementations)
or require all sorts of hacks.

Since the original code has roughly no benefit except in some very
special cases and the effort required to preserve it is very high,
I propose to remove it as agreed on with several other parties.

Please note, that this patch does not change the behaviour of the
functions in RELEASE builds. I.e. they will still check for NULL
and return RETURN_INVALID_PARAMETER. In the future we may (or may
not) want them to simply ASSERT in this case. Regardless this should
be done in a separate BZ entry and a separate commit. For this reason
I ask everyone not to touch this subject.

Due to the amount of discussion this has already undergone after
almost a year I kindly request everyone to reduce the communication
to the minimum and abstain from proposing another approach.

Requesting to merge this into edk2-stable202005.

Cc: Andrew Fish afish@apple.com
Cc: Ard Biesheuvel ard.biesheuvel@linaro.org
Cc: Bret Barkelew bret.barkelew@microsoft.com
Cc: Brian J. Johnson brian.johnson@hpe.com
Cc: Chasel Chiu chasel.chiu@intel.com
Cc: Jordan Justen jordan.l.justen@intel.com
Cc: Laszlo Ersek lersek@redhat.com
Cc: Leif Lindholm leif@nuviainc.com
Cc: Liming Gao liming.gao@intel.com
Cc: Marvin Häuser mhaeuser@outlook.de
Cc: Michael D Kinney michael.d.kinney@intel.com
Cc: Vincent Zimmer vincent.zimmer@intel.com
Cc: Zhichao Gao zhichao.gao@intel.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Vitaly Cheptsov vit9696@protonmail.com

Michael D Kinney (1):
MdePkg/Test/BaseLib: Add SAFE_STRING_CONSTRAINT_CHECK unit test

Vitaly Cheptsov (1):
MdePkg: Fix SafeString performing assertions on runtime checks

MdePkg/Include/Library/BaseLib.h | 111 -----------------
MdePkg/Library/BaseLib/SafeString.c | 115 +-----------------
.../UnitTest/Library/BaseLib/Base64UnitTest.c | 85 +++++++++++++
3 files changed, 88 insertions(+), 223 deletions(-)

--
2.21.0.windows.1


Re: [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement

Zhang, Shenglei
 

Hi,

For this patch, I'd like to catch this stable tag.

Thanks,
Shenglei

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Zhang, Shenglei
Sent: Wednesday, May 20, 2020 11:09 AM
To: devel@edk2.groups.io
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu, Siyuan
<siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
Subject: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order
of conditions in IF statement

The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is
meaningless if Index = 0. So checking 'Index != 0' should be
performed first in the if statement.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update 'Index > 0' to 'Index != 0'

NetworkPkg/Library/DxeNetLib/NetBuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Library/DxeNetLib/NetBuffer.c
b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
index a232802c9a21..329a17623d94 100644
--- a/NetworkPkg/Library/DxeNetLib/NetBuffer.c
+++ b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
@@ -1063,7 +1063,7 @@ NetbufAllocSpace (
} else {
NetbufGetByte (Nbuf, 0, &Index);

- if ((NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len) && (Index > 0)) {
+ if ((Index != 0) && (NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len))
{
Index--;
}
}
--
2.18.0.windows.1



[PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement

Zhang, Shenglei
 

The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is
meaningless if Index = 0. So checking 'Index != 0' should be
performed first in the if statement.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---

v2: Update 'Index > 0' to 'Index != 0'

NetworkPkg/Library/DxeNetLib/NetBuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Library/DxeNetLib/NetBuffer.c b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
index a232802c9a21..329a17623d94 100644
--- a/NetworkPkg/Library/DxeNetLib/NetBuffer.c
+++ b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
@@ -1063,7 +1063,7 @@ NetbufAllocSpace (
} else {
NetbufGetByte (Nbuf, 0, &Index);

- if ((NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len) && (Index > 0)) {
+ if ((Index != 0) && (NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len)) {
Index--;
}
}
--
2.18.0.windows.1


[Patch v8 2/2] MdePkg/Test/BaseLib: Add SAFE_STRING_CONSTRAINT_CHECK unit test

Michael D Kinney
 

Use the safe string function StrCpyS() in BaseLib to test the
SAFE_STRING_CONSTRAINT_CHECK() macro.

Cc: Andrew Fish <afish@apple.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Cc: Brian J. Johnson <brian.johnson@hpe.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Marvin H?user <mhaeuser@outlook.de>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Vincent Zimmer <vincent.zimmer@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
.../UnitTest/Library/BaseLib/Base64UnitTest.c | 85 +++++++++++++++++++
1 file changed, 85 insertions(+)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 8952f9da6c..5aced69e0d 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -290,6 +290,77 @@ RfcDecodeTest(
return UNIT_TEST_PASSED;
}

+#define SOURCE_STRING L"Hello"
+
+STATIC
+UNIT_TEST_STATUS
+EFIAPI
+SafeStringContraintCheckTest (
+ IN UNIT_TEST_CONTEXT Context
+ )
+{
+ RETURN_STATUS Status;
+ CHAR16 Destination[20];
+
+ //
+ // Positive test case copy source unicode string to destination
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_NOT_EFI_ERROR (Status);
+ UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+ //
+ // Positive test case with DestMax the same as Source size
+ //
+ Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_NOT_EFI_ERROR (Status);
+ UT_ASSERT_MEM_EQUAL (Destination, SOURCE_STRING, sizeof (SOURCE_STRING));
+
+ //
+ // Negative test case with Destination NULL
+ //
+ Status = StrCpyS (NULL, sizeof (Destination) / sizeof (CHAR16), SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with Source NULL
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), NULL);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax too big
+ //
+ Status = StrCpyS (Destination, MAX_UINTN, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax 0
+ //
+ Status = StrCpyS (Destination, 0, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_INVALID_PARAMETER);
+
+ //
+ // Negative test case with DestMax smaller than Source size
+ //
+ Status = StrCpyS (Destination, 1, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+
+ //
+ // Negative test case with DestMax smaller than Source size by one character
+ //
+ Status = StrCpyS (Destination, sizeof (SOURCE_STRING) / sizeof (CHAR16) - 1, SOURCE_STRING);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
+
+ //
+ // Negative test case with DestMax smaller than Source size
+ //
+ Status = StrCpyS (Destination, sizeof (Destination) / sizeof (CHAR16), Destination);
+ UT_ASSERT_STATUS_EQUAL (Status, RETURN_ACCESS_DENIED);
+
+ return UNIT_TEST_PASSED;
+}
+
/**
Initialze the unit test framework, suite, and unit tests for the
Base64 conversion APIs of BaseLib and run the unit tests.
@@ -309,6 +380,7 @@ UnitTestingEntry (
UNIT_TEST_FRAMEWORK_HANDLE Fw;
UNIT_TEST_SUITE_HANDLE b64EncodeTests;
UNIT_TEST_SUITE_HANDLE b64DecodeTests;
+ UNIT_TEST_SUITE_HANDLE SafeStringTests;

Fw = NULL;

@@ -367,6 +439,19 @@ UnitTestingEntry (
AddTestCase (b64DecodeTests, "Incorrectly placed padding character", "Error4", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError4);
AddTestCase (b64DecodeTests, "Too small of output buffer", "Error5", RfcDecodeTest, NULL, CleanUpB64TestContext, &mBasicDecodeError5);

+ //
+ // Populate the safe string Unit Test Suite.
+ //
+ Status = CreateUnitTestSuite (&SafeStringTests, Fw, "Safe String", "BaseLib.SafeString", NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for SafeStringTests\n"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto EXIT;
+ }
+
+ // --------------Suite-----------Description--------------Class Name----------Function--------Pre---Post-------------------Context-----------
+ AddTestCase (SafeStringTests, "SAFE_STRING_CONSTRAINT_CHECK", "SafeStringContraintCheckTest", SafeStringContraintCheckTest, NULL, NULL, NULL);
+
//
// Execute the tests.
//
--
2.21.0.windows.1


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

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 <afish@apple.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Bret Barkelew <bret.barkelew@microsoft.com>
Cc: Brian J. Johnson <brian.johnson@hpe.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Marvin H?user <mhaeuser@outlook.de>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Vincent Zimmer <vincent.zimmer@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Vitaly Cheptsov <vit9696@protonmail.com>
---
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 @@ AsciiStrCpyS (

This function is similar as strncpy_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.
@@ -719,8 +691,6 @@ AsciiStrnCpyS (

This function is similar as strcat_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.
@@ -757,8 +727,6 @@ AsciiStrCatS (

This function is similar as strncat_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.
@@ -804,12 +772,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -859,12 +821,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -918,12 +874,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -977,12 +927,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -1533,16 +1477,8 @@ StrHexToUint64 (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1594,16 +1530,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1667,8 +1595,6 @@ StrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
If String is not aligned in a 16-bit boundary, then ASSERT().

@param String Pointer to a Null-terminated Unicode string.
@@ -1703,17 +1629,6 @@ StrToGuid (

If String is not aligned in a 16-bit boundary, then ASSERT().

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumUnicodeStringLength is not zero and Length is greater than
- PcdMaximumUnicodeStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated Unicode string.
@param Length The number of Unicode characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -1804,7 +1719,6 @@ UnicodeStrToAsciiStr (
the upper 8 bits, 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.

@@ -1851,7 +1765,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-zero value in the upper 8
bits, 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.

@@ -2415,10 +2328,6 @@ AsciiStrHexToUint64 (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -2470,10 +2379,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -2535,9 +2440,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Guid Pointer to the converted GUID.

@@ -2568,17 +2470,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and outputs Buffer containing
(Length / 2) bytes.

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumAsciiStringLength is not zero and Length is greater than
- PcdMaximumAsciiStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Length The number of ASCII characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -2659,7 +2550,6 @@ AsciiStrToUnicodeStr (
equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.

If Destination 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.

@@ -2705,7 +2595,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.

If Destination 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 Destination and DestinationLength are
unmodified.
diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
index 7dc03d2caa..3bb23ca1a1 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -14,8 +14,10 @@

#define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status) \
do { \
- ASSERT (Expression); \
if (!(Expression)) { \
+ DEBUG ((DEBUG_VERBOSE, \
+ "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed. Return %r\n", \
+ __FILE__, __LINE__, __FUNCTION__, #Expression, Status)); \
return Status; \
} \
} while (FALSE)
@@ -197,7 +199,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.

@@ -279,7 +280,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.

@@ -372,7 +372,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.

@@ -473,7 +472,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.

@@ -590,12 +588,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.
@@ -705,12 +698,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.
@@ -825,12 +813,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.
@@ -956,12 +939,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.
@@ -1091,16 +1069,8 @@ StrHexToUint64S (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1317,16 +1287,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address 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 EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -1482,8 +1444,6 @@ StrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
If String is not aligned in a 16-bit boundary, then ASSERT().

@param String Pointer to a Null-terminated Unicode string.
@@ -1589,17 +1549,6 @@ StrToGuid (

If String is not aligned in a 16-bit boundary, then ASSERT().

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumUnicodeStringLength is not zero and Length is greater than
- PcdMaximumUnicodeStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated Unicode string.
@param Length The number of Unicode characters to decode.
@param Buffer Pointer to the converted bytes array.
@@ -1779,8 +1728,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.
@@ -1856,8 +1803,6 @@ AsciiStrCpyS (

This function is similar as strncpy_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.
@@ -1944,8 +1889,6 @@ AsciiStrnCpyS (

This function is similar as strcat_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.
@@ -2040,8 +1983,6 @@ AsciiStrCatS (

This function is similar as strncat_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.
@@ -2154,12 +2095,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -2266,12 +2201,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -2382,12 +2311,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINTN, then
@@ -2509,12 +2432,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal character or Null-terminator,
whichever on comes first.

- If String is NULL, then ASSERT().
- If Data is NULL, then ASSERT().
- If PcdMaximumAsciiStringLength is not zero, and String contains more than
- PcdMaximumAsciiStringLength Ascii 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.
If the number represented by String exceeds the range defined by UINT64, then
@@ -2635,7 +2552,6 @@ AsciiStrHexToUint64S (
the upper 8 bits, 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.

@@ -2735,7 +2651,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-zero value in the upper 8
bits, 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 Destination and DestinationLength are
unmodified.
@@ -2855,7 +2770,6 @@ UnicodeStrnToAsciiStrS (
equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.

If Destination 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.

@@ -2948,7 +2862,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.

If Destination 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 Destination and DestinationLength are
unmodified.
@@ -3072,10 +2985,6 @@ AsciiStrnToUnicodeStrS (
"::" can be used to compress one or more groups of X when X contains only 0.
The "::" can only appear once in the String.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -3291,10 +3200,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at the first character that is not
a valid decimal digit character after P is converted.

- If String is NULL, then ASSERT().
-
- If Address is NULL, then ASSERT().
-
If EndPointer is not NULL and Address is translated from String, a pointer
to the character that stopped the scan is stored at the location pointed to
by EndPointer.
@@ -3448,9 +3353,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]
pp Data4[56:63]

- If String is NULL, then ASSERT().
- If Guid is NULL, then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Guid Pointer to the converted GUID.

@@ -3550,17 +3452,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and outputs Buffer containing
(Length / 2) bytes.

- If String is NULL, then ASSERT().
-
- If Buffer is NULL, then ASSERT().
-
- If Length is not multiple of 2, then ASSERT().
-
- If PcdMaximumAsciiStringLength is not zero and Length is greater than
- PcdMaximumAsciiStringLength, then ASSERT().
-
- If MaxBufferSize is less than (Length / 2), then ASSERT().
-
@param String Pointer to a Null-terminated ASCII string.
@param Length The number of ASCII characters to decode.
@param Buffer Pointer to the converted bytes array.
--
2.21.0.windows.1


[Patch v8 0/2] Disable safe string constraint assertions

Michael D Kinney
 

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

V8 Add DEBUG_VERBOSE message and unit test
V7 addressed review comments (only documentation changes).

Current implementation of SafeString does not let one parse untrusted
data with its interfaces as they ASSERT on failing runtime checks and
require one to effectively reimplement the function on the caller side.

All the former proposals made it clear that the attempts to introduce
a solution preserving this behavior require a lot of changes
throughout the codebase including platform code (e.g. introducing
constraint assertions and updating all DebugLib implementations)
or require all sorts of hacks.

Since the original code has roughly no benefit except in some very
special cases and the effort required to preserve it is very high,
I propose to remove it as agreed on with several other parties.

Please note, that this patch does not change the behaviour of the
functions in RELEASE builds. I.e. they will still check for NULL
and return RETURN_INVALID_PARAMETER. In the future we may (or may
not) want them to simply ASSERT in this case. Regardless this should
be done in a separate BZ entry and a separate commit. For this reason
I ask everyone not to touch this subject.

Due to the amount of discussion this has already undergone after
almost a year I kindly request everyone to reduce the communication
to the minimum and abstain from proposing another approach.

Requesting to merge this into edk2-stable202005.

Cc: Andrew Fish afish@apple.com
Cc: Ard Biesheuvel ard.biesheuvel@linaro.org
Cc: Bret Barkelew bret.barkelew@microsoft.com
Cc: Brian J. Johnson brian.johnson@hpe.com
Cc: Chasel Chiu chasel.chiu@intel.com
Cc: Jordan Justen jordan.l.justen@intel.com
Cc: Laszlo Ersek lersek@redhat.com
Cc: Leif Lindholm leif@nuviainc.com
Cc: Liming Gao liming.gao@intel.com
Cc: Marvin Häuser mhaeuser@outlook.de
Cc: Michael D Kinney michael.d.kinney@intel.com
Cc: Vincent Zimmer vincent.zimmer@intel.com
Cc: Zhichao Gao zhichao.gao@intel.com
Cc: Jiewen Yao jiewen.yao@intel.com
Signed-off-by: Vitaly Cheptsov vit9696@protonmail.com

Michael D Kinney (2):
MdePkg: Fix SafeString performing assertions on runtime checks
MdePkg/Test/BaseLib: Add SAFE_STRING_CONSTRAINT_CHECK unit test

MdePkg/Include/Library/BaseLib.h | 111 -----------------
MdePkg/Library/BaseLib/SafeString.c | 115 +-----------------
.../UnitTest/Library/BaseLib/Base64UnitTest.c | 85 +++++++++++++
3 files changed, 88 insertions(+), 223 deletions(-)

--
2.21.0.windows.1


Re: [PATCH V7 1/1] MdePkg: Fix SafeString performing assertions on runtime checks

Michael D Kinney
 

Hi Vitaly,

I think this should work. ASSERT() removed. DEBUG_VERBOSE message added.

#define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status) \
do { \
if (!(Expression)) { \
DEBUG ((DEBUG_VERBOSE, "SAFE_STRING_CONSTRAINT_CHECK(%a) failed. Return %r\n", #Expression, Status)); \
return Status; \
} \
} while (FALSE)

I have made this change in the following PR to run the all the CI checks
and also added a unit test to verify the ASSERT() has been replaced with
a DEBUG_VERBOSE message. I made some minor updates to the commit
messages to pass PatchCheck.py.

https://github.com/tianocore/edk2/pull/632


This is a portion of the CI build log that shows the host based unit
test running and generates the DEBUG_VERBOSE messages for the negative
test cases sent to StrCpyS().

INFO - ---------------------------------------------------------
INFO - RUNNING TEST SUITE: Safe String
INFO - ---------------------------------------------------------
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(236) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((Destination != NULL)) failed. Return Invalid Parameter
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(237) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((Source != NULL)) failed. Return Invalid Parameter
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(243) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((DestMax <= RSIZE_MAX)) failed. Return Invalid Parameter
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(249) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((DestMax != 0)) failed. Return Invalid Parameter
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(255) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((DestMax > SourceLen)) failed. Return Buffer Too Small
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(255) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK((DestMax > SourceLen)) failed. Return Buffer Too Small
INFO - d:\a\1\s\MdePkg\Library\BaseLib\SafeString.c(260) StrCpyS: SAFE_STRING_CONSTRAINT_CHECK(InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1)) failed. Return Access Denied
INFO - ------------------------------------------------
INFO - --------------Cmd Output Finished---------------

I will send the updated V8 series email patches for review shortly.

Best regards,

Mike

-----Original Message-----
From: Vitaly Cheptsov <cheptsov@ispras.ru>
Sent: Monday, May 18, 2020 11:08 AM
To: Kinney, Michael D <michael.d.kinney@intel.com>
Cc: devel@edk2.groups.io; Andrew Fish
<afish@apple.com>; Ard Biesheuvel
<ard.biesheuvel@linaro.org>; Bret Barkelew
<bret.barkelew@microsoft.com>; Brian J . Johnson
<brian.johnson@hpe.com>; Chiu, Chasel
<chasel.chiu@intel.com>; Justen, Jordan L
<jordan.l.justen@intel.com>; Laszlo Ersek
<lersek@redhat.com>; Leif Lindholm <leif@nuviainc.com>;
Gao, Liming <liming.gao@intel.com>; Marvin Häuser
<mhaeuser@outlook.de>; Zimmer, Vincent
<vincent.zimmer@intel.com>; Gao, Zhichao
<zhichao.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH V7 1/1] MdePkg: Fix
SafeString performing assertions on runtime checks

Mike,

Your suggestion sounds ok to me. As long as it is
verbose I will not mind its addition. However, I do not
have a good idea of how can it look like. If you post
something I can include it.

Thanks,
Vitaly

18 мая 2020 г., в 20:04, Kinney, Michael D
<michael.d.kinney@intel.com> написал(а):

Vitaly,

Reviewed-by: Michael D Kinney
<michael.d.kinney@intel.com>

I agree that can go in now for the stable tag.

The only additional comment I have received is if a
DEBUG() message
can be added where the ASSERT() was removed. Perhaps
only at the
DEBUG_VERBOSE level that is not usually enabled by
default. A
developer that wants to see
SAFE_STRING_CONSTRAINT_CHECK() conditions
that fail would need to enable DEBUG_VERBOSE
messages.

Thanks,

Mike


-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On
Behalf Of Vitaly Cheptsov
Sent: Thursday, May 14, 2020 10:32 AM
To: devel@edk2.groups.io
Cc: Andrew Fish <afish@apple.com>; Ard Biesheuvel
<ard.biesheuvel@linaro.org>; Bret Barkelew
<bret.barkelew@microsoft.com>; Brian J . Johnson
<brian.johnson@hpe.com>; Chiu, Chasel
<chasel.chiu@intel.com>; Justen, Jordan L
<jordan.l.justen@intel.com>; Laszlo Ersek
<lersek@redhat.com>; Leif Lindholm
<leif@nuviainc.com>;
Gao, Liming <liming.gao@intel.com>; Marvin Häuser
<mhaeuser@outlook.de>; Kinney, Michael D
<michael.d.kinney@intel.com>; Zimmer, Vincent
<vincent.zimmer@intel.com>; Gao, Zhichao
<zhichao.gao@intel.com>
Subject: [edk2-devel] [PATCH V7 1/1] 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.

CC: Andrew Fish <afish@apple.com>
CC: Ard Biesheuvel <ard.biesheuvel@linaro.org>
CC: Bret Barkelew <bret.barkelew@microsoft.com>
CC: Brian J. Johnson <brian.johnson@hpe.com>
CC: Chasel Chiu <chasel.chiu@intel.com>
CC: Jordan Justen <jordan.l.justen@intel.com>
CC: Laszlo Ersek <lersek@redhat.com>
CC: Leif Lindholm <leif@nuviainc.com>
CC: Liming Gao <liming.gao@intel.com>
CC: Marvin Häuser <mhaeuser@outlook.de>
CC: Mike Kinney <michael.d.kinney@intel.com>
CC: Vincent Zimmer <vincent.zimmer@intel.com>
CC: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Vitaly Cheptsov
<vit9696@protonmail.com>
---
MdePkg/Include/Library/BaseLib.h | 111 ----------
--
-------
MdePkg/Library/BaseLib/SafeString.c | 112 ----------
--
--------
2 files changed, 223 deletions(-)

diff --git a/MdePkg/Include/Library/BaseLib.h
b/MdePkg/Include/Library/BaseLib.h
index ecadff8b23..2c194ad943 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -189,7 +189,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.





@@ -225,7 +224,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.





@@ -263,7 +261,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.





@@ -303,7 +300,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.





@@ -350,12 +346,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.


@@ -406,12 +397,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.


@@ -467,12 +453,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.


@@ -528,12 +509,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.


@@ -622,8 +598,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.


@@ -656,8 +630,6 @@ AsciiStrCpyS (



This function is similar as strncpy_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.


@@ -692,8 +664,6 @@ AsciiStrnCpyS (



This function is similar as strcat_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.


@@ -730,8 +700,6 @@ AsciiStrCatS (



This function is similar as strncat_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.


@@ -777,12 +745,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINTN, then


@@ -832,12 +794,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINT64, then


@@ -891,12 +847,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal
character or Null-terminator,


whichever on comes first.





- If String is NULL, then ASSERT().


- If Data is NULL, then ASSERT().


- If PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINTN, then


@@ -950,12 +900,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal
character or Null-terminator,


whichever on comes first.





- If String is NULL, then ASSERT().


- If Data is NULL, then ASSERT().


- If PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINT64, then


@@ -1506,16 +1450,8 @@ StrHexToUint64 (
"::" can be used to compress one or more groups of
X
when X contains only 0.


The "::" can only appear once in the String.





- If String is NULL, then ASSERT().


-


- If Address 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 EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -1567,16 +1503,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at
the
first character that is not


a valid decimal digit character after P is
converted.





- If String is NULL, then ASSERT().


-


- If Address 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 EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -1640,8 +1568,6 @@ StrToIpv4Address (
oo Data4[48:55]


pp Data4[56:63]





- If String is NULL, then ASSERT().


- If Guid is NULL, then ASSERT().


If String is not aligned in a 16-bit boundary,
then
ASSERT().





@param String Pointer to a
Null-
terminated Unicode string.


@@ -1676,17 +1602,6 @@ StrToGuid (



If String is not aligned in a 16-bit boundary,
then
ASSERT().





- If String is NULL, then ASSERT().


-


- If Buffer is NULL, then ASSERT().


-


- If Length is not multiple of 2, then ASSERT().


-


- If PcdMaximumUnicodeStringLength is not zero and
Length is greater than


- PcdMaximumUnicodeStringLength, then ASSERT().


-


- If MaxBufferSize is less than (Length / 2), then
ASSERT().


-


@param String Pointer to a
Null-
terminated Unicode string.


@param Length The number of
Unicode characters to decode.


@param Buffer Pointer to the
converted bytes array.


@@ -1777,7 +1692,6 @@ UnicodeStrToAsciiStr (
the upper 8 bits, 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.





@@ -1824,7 +1738,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-
zero
value in the upper 8


bits, 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.





@@ -2388,10 +2301,6 @@ AsciiStrHexToUint64 (
"::" can be used to compress one or more groups of
X
when X contains only 0.


The "::" can only appear once in the String.





- If String is NULL, then ASSERT().


-


- If Address is NULL, then ASSERT().


-


If EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -2443,10 +2352,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at
the
first character that is not


a valid decimal digit character after P is
converted.





- If String is NULL, then ASSERT().


-


- If Address is NULL, then ASSERT().


-


If EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -2508,9 +2413,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]


pp Data4[56:63]





- If String is NULL, then ASSERT().


- If Guid is NULL, then ASSERT().


-


@param String Pointer to a
Null-
terminated ASCII string.


@param Guid Pointer to the
converted GUID.





@@ -2541,17 +2443,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and
outputs Buffer containing


(Length / 2) bytes.





- If String is NULL, then ASSERT().


-


- If Buffer is NULL, then ASSERT().


-


- If Length is not multiple of 2, then ASSERT().


-


- If PcdMaximumAsciiStringLength is not zero and
Length is greater than


- PcdMaximumAsciiStringLength, then ASSERT().


-


- If MaxBufferSize is less than (Length / 2), then
ASSERT().


-


@param String Pointer to a
Null-
terminated ASCII string.


@param Length The number of
ASCII
characters to decode.


@param Buffer Pointer to the
converted bytes array.


@@ -2632,7 +2523,6 @@ AsciiStrToUnicodeStr (
equal or greater than ((AsciiStrLen (Source) + 1)
*
sizeof (CHAR16)) in bytes.





If Destination 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.





@@ -2678,7 +2568,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof
(CHAR8)) in bytes.





If Destination 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 Destination and
DestinationLength are


unmodified.


diff --git a/MdePkg/Library/BaseLib/SafeString.c
b/MdePkg/Library/BaseLib/SafeString.c
index 7dc03d2caa..41d9137b83 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -14,7 +14,6 @@



#define SAFE_STRING_CONSTRAINT_CHECK(Expression,
Status) \


do { \


- ASSERT (Expression); \


if (!(Expression)) { \


return Status; \


} \


@@ -197,7 +196,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.





@@ -279,7 +277,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.





@@ -372,7 +369,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.





@@ -473,7 +469,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.





@@ -590,12 +585,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.


@@ -705,12 +695,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.


@@ -825,12 +810,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.


@@ -956,12 +936,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.


@@ -1091,16 +1066,8 @@ StrHexToUint64S (
"::" can be used to compress one or more groups of
X
when X contains only 0.


The "::" can only appear once in the String.





- If String is NULL, then ASSERT().


-


- If Address 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 EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -1317,16 +1284,8 @@ StrToIpv6Address (
When /P is in the String, the function stops at
the
first character that is not


a valid decimal digit character after P is
converted.





- If String is NULL, then ASSERT().


-


- If Address 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 EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -1482,8 +1441,6 @@ StrToIpv4Address (
oo Data4[48:55]


pp Data4[56:63]





- If String is NULL, then ASSERT().


- If Guid is NULL, then ASSERT().


If String is not aligned in a 16-bit boundary,
then
ASSERT().





@param String Pointer to a
Null-
terminated Unicode string.


@@ -1589,17 +1546,6 @@ StrToGuid (



If String is not aligned in a 16-bit boundary,
then
ASSERT().





- If String is NULL, then ASSERT().


-


- If Buffer is NULL, then ASSERT().


-


- If Length is not multiple of 2, then ASSERT().


-


- If PcdMaximumUnicodeStringLength is not zero and
Length is greater than


- PcdMaximumUnicodeStringLength, then ASSERT().


-


- If MaxBufferSize is less than (Length / 2), then
ASSERT().


-


@param String Pointer to a
Null-
terminated Unicode string.


@param Length The number of
Unicode characters to decode.


@param Buffer Pointer to the
converted bytes array.


@@ -1779,8 +1725,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.


@@ -1856,8 +1800,6 @@ AsciiStrCpyS (



This function is similar as strncpy_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.


@@ -1944,8 +1886,6 @@ AsciiStrnCpyS (



This function is similar as strcat_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.


@@ -2040,8 +1980,6 @@ AsciiStrCatS (



This function is similar as strncat_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.


@@ -2154,12 +2092,6 @@ AsciiStrnCatS (
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 PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINTN, then


@@ -2266,12 +2198,6 @@ AsciiStrDecimalToUintnS (
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 PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINT64, then


@@ -2382,12 +2308,6 @@ AsciiStrDecimalToUint64S (
character that is a not a valid hexadecimal
character or Null-terminator,


whichever on comes first.





- If String is NULL, then ASSERT().


- If Data is NULL, then ASSERT().


- If PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINTN, then


@@ -2509,12 +2429,6 @@ AsciiStrHexToUintnS (
character that is a not a valid hexadecimal
character or Null-terminator,


whichever on comes first.





- If String is NULL, then ASSERT().


- If Data is NULL, then ASSERT().


- If PcdMaximumAsciiStringLength is not zero, and
String contains more than


- PcdMaximumAsciiStringLength Ascii 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.


If the number represented by String exceeds the
range defined by UINT64, then


@@ -2635,7 +2549,6 @@ AsciiStrHexToUint64S (
the upper 8 bits, 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.





@@ -2735,7 +2648,6 @@ UnicodeStrToAsciiStrS (
If any Unicode characters in Source contain non-
zero
value in the upper 8


bits, 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 Destination and
DestinationLength are


unmodified.


@@ -2855,7 +2767,6 @@ UnicodeStrnToAsciiStrS (
equal or greater than ((AsciiStrLen (Source) + 1)
*
sizeof (CHAR16)) in bytes.





If Destination 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.





@@ -2948,7 +2859,6 @@ AsciiStrToUnicodeStrS (
((MIN(AsciiStrLen(Source), Length) + 1) * sizeof
(CHAR8)) in bytes.





If Destination 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 Destination and
DestinationLength are


unmodified.


@@ -3072,10 +2982,6 @@ AsciiStrnToUnicodeStrS (
"::" can be used to compress one or more groups of
X
when X contains only 0.


The "::" can only appear once in the String.





- If String is NULL, then ASSERT().


-


- If Address is NULL, then ASSERT().


-


If EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -3291,10 +3197,6 @@ AsciiStrToIpv6Address (
When /P is in the String, the function stops at
the
first character that is not


a valid decimal digit character after P is
converted.





- If String is NULL, then ASSERT().


-


- If Address is NULL, then ASSERT().


-


If EndPointer is not NULL and Address is
translated
from String, a pointer


to the character that stopped the scan is stored
at
the location pointed to


by EndPointer.


@@ -3448,9 +3350,6 @@ AsciiStrToIpv4Address (
oo Data4[48:55]


pp Data4[56:63]





- If String is NULL, then ASSERT().


- If Guid is NULL, then ASSERT().


-


@param String Pointer to a
Null-
terminated ASCII string.


@param Guid Pointer to the
converted GUID.





@@ -3550,17 +3449,6 @@ AsciiStrToGuid (
decoding stops after Length of characters and
outputs Buffer containing


(Length / 2) bytes.





- If String is NULL, then ASSERT().


-


- If Buffer is NULL, then ASSERT().


-


- If Length is not multiple of 2, then ASSERT().


-


- If PcdMaximumAsciiStringLength is not zero and
Length is greater than


- PcdMaximumAsciiStringLength, then ASSERT().


-


- If MaxBufferSize is less than (Length / 2), then
ASSERT().


-


@param String Pointer to a
Null-
terminated ASCII string.


@param Length The number of
ASCII
characters to decode.


@param Buffer Pointer to the
converted bytes array.


--
2.24.2 (Apple Git-127)



[PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement

Zhang, Shenglei
 


Updated Event: TianoCore Bug Triage - APAC / NAMO #cal-invite

devel@edk2.groups.io Calendar <devel@...>
 

TianoCore Bug Triage - APAC / NAMO

When:
Tuesday, 26 May 2020
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles
Repeats: Weekly on Tuesday

Where:
https://bluejeans.com/889357567?src=join_info

Organizer: Brian Richardson brian.richardson@...

Description:

https://www.tianocore.org/bug-triage

 

Meeting URL

https://bluejeans.com/889357567?src=join_info

 

Meeting ID

889 357 567

 

Want to dial in from a phone?

Dial one of the following numbers:

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

 

(see all numbers - https://www.bluejeans.com/numbers)

Enter the meeting ID and passcode followed by #


Updated Event: TianoCore Bug Triage - APAC / NAMO #cal-invite

devel@edk2.groups.io Calendar <devel@...>
 

TianoCore Bug Triage - APAC / NAMO

When:
Tuesday, 26 May 2020
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles
Repeats: Weekly on Wednesday

Where:
https://bluejeans.com/889357567?src=join_info

Organizer: Brian Richardson brian.richardson@...

Description:

https://www.tianocore.org/bug-triage

 

Meeting URL

https://bluejeans.com/889357567?src=join_info

 

Meeting ID

889 357 567

 

Want to dial in from a phone?

Dial one of the following numbers:

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

 

(see all numbers - https://www.bluejeans.com/numbers)

Enter the meeting ID and passcode followed by #


Updated Event: TianoCore Bug Triage - APAC / NAMO #cal-invite

devel@edk2.groups.io Calendar <devel@...>
 

TianoCore Bug Triage - APAC / NAMO

When:
Tuesday, 2 June 2020
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles
Repeats: Weekly on Wednesday

Where:
https://bluejeans.com/889357567?src=join_info

Organizer: Brian Richardson brian.richardson@...

Description:

https://www.tianocore.org/bug-triage

 

Meeting URL

https://bluejeans.com/889357567?src=join_info

 

Meeting ID

889 357 567

 

Want to dial in from a phone?

Dial one of the following numbers:

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

 

(see all numbers - https://www.bluejeans.com/numbers)

Enter the meeting ID and passcode followed by #


Upcoming Event: TianoCore Bug Triage - APAC / NAMO - Wed, 05/20/2020 9:30am-10:30am #cal-reminder

devel@edk2.groups.io Calendar <devel@...>
 

Reminder: TianoCore Bug Triage - APAC / NAMO

When: Wednesday, 20 May 2020, 9:30am to 10:30am, (GMT+08:00) Asia/Chongqing

Where:https://bluejeans.com/889357567?src=join_info

View Event

Organizer: Brian Richardson brian.richardson@...

Description:

https://www.tianocore.org/bug-triage

 

Meeting URL

https://bluejeans.com/889357567?src=join_info

 

Meeting ID

889 357 567

 

Want to dial in from a phone?

Dial one of the following numbers:

+1.408.740.7256 (US (San Jose))

+1.408.317.9253 (US (Primary, San Jose))

 

(see all numbers - https://www.bluejeans.com/numbers)

Enter the meeting ID and passcode followed by #


Re: [PATCH v7 1/7] MdePkg: Extend SERIAL_IO with DeviceTypeGuid

Guomin Jiang
 

Sorry for reply later.

I understood and the series is good to me.

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

-----Original Message-----
From: Oleksiy Yakovlev <Oleksiyy@ami.com>
Sent: Thursday, May 14, 2020 10:17 PM
To: Jiang, Guomin <guomin.jiang@intel.com>; devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
<liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>;
Felix Polyudov <Felixp@ami.com>
Subject: RE: [edk2-devel] [PATCH v7 1/7] MdePkg: Extend SERIAL_IO with
DeviceTypeGuid

There was a mistake in all previous v here.
I took it from original ECR and misted correction.
Now it is up to spec.

Regards, Oleksiy.

-----Original Message-----
From: Jiang, Guomin [mailto:guomin.jiang@intel.com]
Sent: Wednesday, May 13, 2020 11:43 PM
To: devel@edk2.groups.io; Oleksiy Yakovlev
Cc: Feng, Bob C; Gao, Liming; Kinney, Michael D; Felix Polyudov
Subject: RE: [edk2-devel] [PATCH v7 1/7] MdePkg: Extend SERIAL_IO with
DeviceTypeGuid

Add some comments.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
Oleksiy
Yakovlev
Sent: Thursday, May 14, 2020 3:53 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming
<liming.gao@intel.com>; Kinney, Michael D
<michael.d.kinney@intel.com>; Felixp@ami.com; oleksiyy@ami.com
Subject: [edk2-devel] [PATCH v7 1/7] MdePkg: Extend SERIAL_IO with
DeviceTypeGuid

EFI_SERIAL_IO_PROTOCOL_REVISION incremented to 0x00010001.
CONST EFI_GUID *DeviceTypeGuid field added to the protocol structure.
UEFI 2.8 mantis 1832.

Signed-off-by: Oleksiy Yakovlev <oleksiyy@ami.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>
---
MdePkg/Include/Protocol/SerialIo.h | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/MdePkg/Include/Protocol/SerialIo.h
b/MdePkg/Include/Protocol/SerialIo.h
index 51eaa53..e2e0c61 100644
--- a/MdePkg/Include/Protocol/SerialIo.h
+++ b/MdePkg/Include/Protocol/SerialIo.h
@@ -263,6 +263,7 @@ typedef struct {
} EFI_SERIAL_IO_MODE;

#define EFI_SERIAL_IO_PROTOCOL_REVISION 0x00010000
+#define EFI_SERIAL_IO_PROTOCOL_REVISION1p1 0x00010001
Why add this new definition, it is not exist in patch v5 but exist in patch v6?

#define SERIAL_IO_INTERFACE_REVISION
EFI_SERIAL_IO_PROTOCOL_REVISION

///
@@ -287,6 +288,14 @@ struct _EFI_SERIAL_IO_PROTOCOL {
/// Pointer to SERIAL_IO_MODE data.
///
EFI_SERIAL_IO_MODE *Mode;
+ ///
+ /// Pointer to a GUID identifying the device connected to the serial port.
+ /// This field is NULL when the protocol is installed by the serial
+ port /// driver and may be populated by a platform driver for a
+ serial port /// with a known device attached. The field will remain
+ NULL if there is /// no platform serial device identification
+ information
available.
+ ///
+ CONST EFI_GUID *DeviceTypeGuid; // Revision 1.1
};

extern EFI_GUID gEfiSerialIoProtocolGuid;
--
2.9.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and
proprietary to American Megatrends (AMI). This communication is
intended to be read only by the individual or entity to whom it is
addressed or by their designee. If the reader of this message is not
the intended recipient, you are on notice that any distribution of
this message, in any form, is strictly prohibited. Please promptly
notify the sender by reply e-mail or by telephone at 770-246-8600, and
then delete or destroy all copies of the transmission.


Please consider the environment before printing this email.

The information contained in this message may be confidential and
proprietary to American Megatrends (AMI). This communication is intended
to be read only by the individual or entity to whom it is addressed or by their
designee. If the reader of this message is not the intended recipient, you are
on notice that any distribution of this message, in any form, is strictly
prohibited. Please promptly notify the sender by reply e-mail or by
telephone at 770-246-8600, and then delete or destroy all copies of the
transmission.


Re: [edk2-platforms] [PATCH] SpiTool: Fix spelling errors

Guomin Jiang
 

Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nate
DeSimone
Sent: Tuesday, May 19, 2020 2:21 PM
To: devel@edk2.groups.io
Cc: Marcin Wojtas <mw@semihalf.com>; Leif Lindholm <leif@nuviainc.com>
Subject: [edk2-devel] [edk2-platforms] [PATCH] SpiTool: Fix spelling errors

"beggining" should be "beginning"

Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Marcin Wojtas <mw@semihalf.com>
Cc: Leif Lindholm <leif@nuviainc.com>
---
Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.c | 3 ++-
Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.uni | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.c
b/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.c
index 7ff45b6a9c..46871de688 100644
--- a/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.c
+++ b/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.c
@@ -1,5 +1,6 @@

/**********************************************************
*********************
Copyright (C) 2016 Marvell International Ltd.
+Copyright (c) 2020, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -83,7 +84,7 @@ SfUsage (
"Length - Number of bytes to send\n"
"Address - Address in RAM to store/load data\n"
"FilePath - Path to file to read/write data from/to\n"
- "Offset - Offset from beggining of SPI flash to store/load data\n"
+ "Offset - Offset from beginning of SPI flash to store/load data\n"
"Examples:\n"
"Check if there is response from SPI flash\n"
" sf probe\n"
diff --git a/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.uni
b/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.uni
index 57a9109ee7..3cec099732 100644
--- a/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.uni
+++ b/Silicon/Marvell/Applications/SpiTool/SpiFlashCmd.uni
@@ -1,5 +1,6 @@

/**********************************************************
*********************
Copyright (C) 2016 Marvell International Ltd.
+Copyright (c) 2020, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -21,7 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent " \r\n"
" Length - Number of bytes to send\r\n"
" Address - Address in RAM to store/load data\r\n"
-" Offset - Offset from beggining of SPI flash to store/load data\r\n"
+" Offset - Offset from beginning of SPI flash to store/load data\r\n"
" FilePath - Path to file to read data into or write/update data from \r\n"
".SH EXAMPLES\r\n"
" \r\n"
--
2.26.0.windows.1