public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData
@ 2020-03-24  1:42 Guomin Jiang
  2020-03-24 15:52 ` Michael D Kinney
  2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew
  0 siblings, 2 replies; 3+ messages in thread
From: Guomin Jiang @ 2020-03-24  1:42 UTC (permalink / raw)
  To: devel; +Cc: 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: Guomin Jiang <guomin.jiang@intel.com>
---
 MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 6f7c31cab4..8952f9da6c 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -252,9 +252,11 @@ RfcDecodeTest(
   BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);
 
   BinData = AllocatePool (BinSize);
-  Btc->BufferToFree = BinData;
+  UT_ASSERT_NOT_NULL(BinData);
 
+  Btc->BufferToFree = BinData;
   ReturnSize = BinSize;
+
   Status = Base64Decode (b64String, b64StringLen, BinData, &ReturnSize);
 
   UT_ASSERT_STATUS_EQUAL (Status, Btc->ExpectedStatus);
-- 
2.25.1.windows.1


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

* Re: [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData
  2020-03-24  1:42 [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData Guomin Jiang
@ 2020-03-24 15:52 ` Michael D Kinney
  2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew
  1 sibling, 0 replies; 3+ messages in thread
From: Michael D Kinney @ 2020-03-24 15:52 UTC (permalink / raw)
  To: Jiang, Guomin, devel@edk2.groups.io, Kinney, Michael D; +Cc: Gao, Liming

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

Mike

> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Monday, March 23, 2020 6:43 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
> Gao, Liming <liming.gao@intel.com>
> Subject: [PATCH v4] MdePkg/UnitTestBaseLib: Add check
> for pointer BinData
> 
> 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: Guomin Jiang <guomin.jiang@intel.com>
> ---
>  MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git
> a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> index 6f7c31cab4..8952f9da6c 100644
> ---
> a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> +++
> b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
> @@ -252,9 +252,11 @@ RfcDecodeTest(
>    BinSize = AsciiStrnLenS (binString,
> MAX_TEST_STRING_SIZE);
> 
> 
> 
>    BinData = AllocatePool (BinSize);
> 
> -  Btc->BufferToFree = BinData;
> 
> +  UT_ASSERT_NOT_NULL(BinData);
> 
> 
> 
> +  Btc->BufferToFree = BinData;
> 
>    ReturnSize = BinSize;
> 
> +
> 
>    Status = Base64Decode (b64String, b64StringLen,
> BinData, &ReturnSize);
> 
> 
> 
>    UT_ASSERT_STATUS_EQUAL (Status, Btc-
> >ExpectedStatus);
> 
> --
> 2.25.1.windows.1


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

* Re: [EXTERNAL] [edk2-devel] [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData
  2020-03-24  1:42 [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData Guomin Jiang
  2020-03-24 15:52 ` Michael D Kinney
@ 2020-03-24 17:38 ` Bret Barkelew
  1 sibling, 0 replies; 3+ messages in thread
From: Bret Barkelew @ 2020-03-24 17:38 UTC (permalink / raw)
  To: devel@edk2.groups.io, guomin.jiang@intel.com
  Cc: Kinney, Michael D, Liming Gao

[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]

Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>

- Bret

________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Guomin Jiang via Groups.Io <guomin.jiang=intel.com@groups.io>
Sent: Monday, March 23, 2020 6:42:41 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <liming.gao@intel.com>
Subject: [EXTERNAL] [edk2-devel] [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData

REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2531&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682048750&amp;sdata=QwoKvxc7kKhrL0d00VidlcmAUV52ERnXnvjZl%2B30iBo%3D&amp;reserved=0

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: Guomin Jiang <guomin.jiang@intel.com>
---
 MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
index 6f7c31cab4..8952f9da6c 100644
--- a/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
+++ b/MdePkg/Test/UnitTest/Library/BaseLib/Base64UnitTest.c
@@ -252,9 +252,11 @@ RfcDecodeTest(
   BinSize = AsciiStrnLenS (binString, MAX_TEST_STRING_SIZE);



   BinData = AllocatePool (BinSize);

-  Btc->BufferToFree = BinData;

+  UT_ASSERT_NOT_NULL(BinData);



+  Btc->BufferToFree = BinData;

   ReturnSize = BinSize;

+

   Status = Base64Decode (b64String, b64StringLen, BinData, &ReturnSize);



   UT_ASSERT_STATUS_EQUAL (Status, Btc->ExpectedStatus);

--
2.25.1.windows.1


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

View/Reply Online (#56125): https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F56125&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&amp;sdata=JDn7W7TIK1N88KwHk%2FUfPlBr2K7ZZWXSHuHi8g4hFzQ%3D&amp;reserved=0
Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F72508893%2F1852292&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&amp;sdata=S%2FvxBwgQopFui1%2FiSzYWl2svWyrik8%2FoBr3nBHDtlN4%3D&amp;reserved=0
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&amp;data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&amp;sdata=cqEooo1lTCAXYRPN6CQhdKcGRXTC4XTZMz7FSl6Zq8I%3D&amp;reserved=0  [bret.barkelew@microsoft.com]
-=-=-=-=-=-=


[-- Attachment #2: Type: text/html, Size: 6661 bytes --]

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

end of thread, other threads:[~2020-03-24 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-24  1:42 [PATCH v4] MdePkg/UnitTestBaseLib: Add check for pointer BinData Guomin Jiang
2020-03-24 15:52 ` Michael D Kinney
2020-03-24 17:38 ` [EXTERNAL] [edk2-devel] " Bret Barkelew

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