[edk2-devel] [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked

GuoMinJ posted 1 patch 4 years, 1 month ago
Failed in applying to current master (apply log)
MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 3 +++
1 file changed, 3 insertions(+)
[edk2-devel] [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked
Posted by GuoMinJ 4 years, 1 month ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2531

AllocatePool may fail and BinData may be invalid, check
it before use.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
---
 MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 6f7c31cab4..933d2b40e0 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -252,6 +252,9 @@ RfcDecodeTest(
   BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);
 
   BinData = AllocatePool (BinSize);
+  if (BinData == NULL) {
+    return UNIT_TEST_ERROR_TEST_FAILED;
+  }
   Btc->BufferToFree = BinData;
 
   ReturnSize = BinSize;
-- 
2.17.1


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

View/Reply Online (#55468): https://edk2.groups.io/g/devel/message/55468
Mute This Topic: https://groups.io/mt/71742540/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked
Posted by Zhang, Shenglei 4 years, 1 month ago
Please update the subject " MdePkg/UnitTestBaseLib: Add check for pointer BinData"
With this updated, Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com>

We should try to describe the changes in subject rather than a problem it fixes.
It can be described in the body of commit message. 

Thanks,
Shenglei

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> GuoMinJ
> Sent: Thursday, March 5, 2020 11:40 AM
> To: devel@edk2.groups.io
> Cc: GuoMinJ <newexplorerj@gmail.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>
> Subject: [edk2-devel] [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData
> need to be checked
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2531
> 
> AllocatePool may fail and BinData may be invalid, check
> it before use.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> ---
>  MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> index 6f7c31cab4..933d2b40e0 100644
> --- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> +++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> @@ -252,6 +252,9 @@ RfcDecodeTest(
>    BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);
> 
>    BinData = AllocatePool (BinSize);
> +  if (BinData == NULL) {
> +    return UNIT_TEST_ERROR_TEST_FAILED;
> +  }
>    Btc->BufferToFree = BinData;
> 
>    ReturnSize = BinSize;
> --
> 2.17.1
> 
> 
> 


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

View/Reply Online (#55470): https://edk2.groups.io/g/devel/message/55470
Mute This Topic: https://groups.io/mt/71742540/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-