public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked
@ 2020-03-05  3:40 GuoMinJ
  2020-03-05  5:12 ` [edk2-devel] " Zhang, Shenglei
  0 siblings, 1 reply; 2+ messages in thread
From: GuoMinJ @ 2020-03-05  3:40 UTC (permalink / raw)
  To: devel; +Cc: GuoMinJ, Michael D Kinney, Liming Gao

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [edk2-devel] [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked
  2020-03-05  3:40 [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked GuoMinJ
@ 2020-03-05  5:12 ` Zhang, Shenglei
  0 siblings, 0 replies; 2+ messages in thread
From: Zhang, Shenglei @ 2020-03-05  5:12 UTC (permalink / raw)
  To: devel@edk2.groups.io, newexplorerj@gmail.com
  Cc: Kinney, Michael D, Gao, Liming

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
> 
> 
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-05  5:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-05  3:40 [PATCH v2] MdePkg/UnitTestBaseLib: Pointer BinData need to be checked GuoMinJ
2020-03-05  5:12 ` [edk2-devel] " Zhang, Shenglei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox