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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#56125): https://edk2.groups.io/g/devel/message/56125
Mute This Topic: https://groups.io/mt/72508893/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56160): https://edk2.groups.io/g/devel/message/56160 Mute This Topic: https://groups.io/mt/72508893/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
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&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682048750&sdata=QwoKvxc7kKhrL0d00VidlcmAUV52ERnXnvjZl%2B30iBo%3D&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&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&sdata=JDn7W7TIK1N88KwHk%2FUfPlBr2K7ZZWXSHuHi8g4hFzQ%3D&reserved=0 Mute This Topic: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.io%2Fmt%2F72508893%2F1852292&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&sdata=S%2FvxBwgQopFui1%2FiSzYWl2svWyrik8%2FoBr3nBHDtlN4%3D&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&data=02%7C01%7Cbret.barkelew%40microsoft.com%7C6522fbf200f848652e0508d7cf94a6e3%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637206109682058707&sdata=cqEooo1lTCAXYRPN6CQhdKcGRXTC4XTZMz7FSl6Zq8I%3D&reserved=0 [bret.barkelew@microsoft.com] -=-=-=-=-=-= -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56170): https://edk2.groups.io/g/devel/message/56170 Mute This Topic: https://groups.io/mt/72522768/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.