public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
@ 2020-03-05  6:17 GuoMinJ
  2020-03-12  6:02 ` [edk2-devel] " Zhang, Shenglei
  0 siblings, 1 reply; 5+ messages in thread
From: GuoMinJ @ 2020-03-05  6:17 UTC (permalink / raw)
  To: devel; +Cc: GuoMinJ, Michael D Kinney, Sean Brogan, Bret Barkelew

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

The Suite pointer is used before check if it is valid,
correct it to check the validation before use.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
---
 UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c    | 6 +++---
 UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
index fb247c59e7..b053e04959 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
@@ -33,13 +33,13 @@ RunTestSuite (
   UNIT_TEST             *Test;
   UNIT_TEST_FRAMEWORK   *ParentFramework;
 
-  TestEntry       = NULL;
-  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
-
   if (Suite == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
+  TestEntry       = NULL;
+  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
+
   DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
   DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));
   DEBUG ((DEBUG_VERBOSE, "---------------------------------------------------------\n"));
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index fd15991ea4..b136992d99 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -436,7 +436,6 @@ AddTestCase (
 
   Status          = EFI_SUCCESS;
   Suite           = (UNIT_TEST_SUITE *)SuiteHandle;
-  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
 
   //
   // First, let's check to make sure that our parameters look good.
@@ -445,6 +444,7 @@ AddTestCase (
     return EFI_INVALID_PARAMETER;
   }
 
+  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
   //
   // Create the new entry.
   NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));
-- 
2.17.1


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

* Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
  2020-03-05  6:17 [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use GuoMinJ
@ 2020-03-12  6:02 ` Zhang, Shenglei
  2020-03-23  6:08   ` Guomin Jiang
  0 siblings, 1 reply; 5+ messages in thread
From: Zhang, Shenglei @ 2020-03-12  6:02 UTC (permalink / raw)
  To: devel@edk2.groups.io, newexplorerj@gmail.com
  Cc: Kinney, Michael D, Sean Brogan, Bret Barkelew

Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> GuoMinJ
> Sent: Thursday, March 5, 2020 2:18 PM
> To: devel@edk2.groups.io
> Cc: GuoMinJ <newexplorerj@gmail.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Sean Brogan <sean.brogan@microsoft.com>;
> Bret Barkelew <Bret.Barkelew@microsoft.com>
> Subject: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check
> Suite pointer before use.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2530
> 
> The Suite pointer is used before check if it is valid,
> correct it to check the validation before use.
> 
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>
> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> ---
>  UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c    | 6 +++---
>  UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> index fb247c59e7..b053e04959 100644
> --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> @@ -33,13 +33,13 @@ RunTestSuite (
>    UNIT_TEST             *Test;
>    UNIT_TEST_FRAMEWORK   *ParentFramework;
> 
> -  TestEntry       = NULL;
> -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
> -
>    if (Suite == NULL) {
>      return EFI_INVALID_PARAMETER;
>    }
> 
> +  TestEntry       = NULL;
> +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> >ParentFramework;
> +
>    DEBUG ((DEBUG_VERBOSE, "--------------------------------------------------------
> -\n"));
>    DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));
>    DEBUG ((DEBUG_VERBOSE, "--------------------------------------------------------
> -\n"));
> diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> index fd15991ea4..b136992d99 100644
> --- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> @@ -436,7 +436,6 @@ AddTestCase (
> 
>    Status          = EFI_SUCCESS;
>    Suite           = (UNIT_TEST_SUITE *)SuiteHandle;
> -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
> 
>    //
>    // First, let's check to make sure that our parameters look good.
> @@ -445,6 +444,7 @@ AddTestCase (
>      return EFI_INVALID_PARAMETER;
>    }
> 
> +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> >ParentFramework;
>    //
>    // Create the new entry.
>    NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));
> --
> 2.17.1
> 
> 
> 


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

* Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
  2020-03-12  6:02 ` [edk2-devel] " Zhang, Shenglei
@ 2020-03-23  6:08   ` Guomin Jiang
  2020-03-23 18:00     ` Michael D Kinney
  0 siblings, 1 reply; 5+ messages in thread
From: Guomin Jiang @ 2020-03-23  6:08 UTC (permalink / raw)
  To: devel@edk2.groups.io, Zhang, Shenglei, newexplorerj@gmail.com
  Cc: Kinney, Michael D, Sean Brogan, Bret Barkelew

Hi Michael, Sean, Bret,

Could you review the patch?

Thanks

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Thursday, March 12, 2020 2:02 PM
> To: devel@edk2.groups.io; newexplorerj@gmail.com
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Sean Brogan
> <sean.brogan@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib:
> Check Suite pointer before use.
> 
> Reviewed-by: Shenglei Zhang <shenglei.zhang@intel.com>
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> > GuoMinJ
> > Sent: Thursday, March 5, 2020 2:18 PM
> > To: devel@edk2.groups.io
> > Cc: GuoMinJ <newexplorerj@gmail.com>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; Sean Brogan
> <sean.brogan@microsoft.com>;
> > Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Subject: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib:
> > Check Suite pointer before use.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2530
> >
> > The Suite pointer is used before check if it is valid, correct it to
> > check the validation before use.
> >
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> > ---
> >  UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c    | 6 +++---
> >  UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 2 +-
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > index fb247c59e7..b053e04959 100644
> > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > @@ -33,13 +33,13 @@ RunTestSuite (
> >    UNIT_TEST             *Test;
> >    UNIT_TEST_FRAMEWORK   *ParentFramework;
> >
> > -  TestEntry       = NULL;
> > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> >ParentFramework;
> > -
> >    if (Suite == NULL) {
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > +  TestEntry       = NULL;
> > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> > +
> >    DEBUG ((DEBUG_VERBOSE,
> > "--------------------------------------------------------
> > -\n"));
> >    DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE: %a\n", Suite->Title));
> >    DEBUG ((DEBUG_VERBOSE,
> > "--------------------------------------------------------
> > -\n"));
> > diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> > b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> > index fd15991ea4..b136992d99 100644
> > --- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> > +++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> > @@ -436,7 +436,6 @@ AddTestCase (
> >
> >    Status          = EFI_SUCCESS;
> >    Suite           = (UNIT_TEST_SUITE *)SuiteHandle;
> > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> >ParentFramework;
> >
> >    //
> >    // First, let's check to make sure that our parameters look good.
> > @@ -445,6 +444,7 @@ AddTestCase (
> >      return EFI_INVALID_PARAMETER;
> >    }
> >
> > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> >    //
> >    // Create the new entry.
> >    NewTestEntry = AllocateZeroPool (sizeof( UNIT_TEST_LIST_ENTRY ));
> > --
> > 2.17.1
> >
> >
> >
> 
> 
> 


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

* Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
  2020-03-23  6:08   ` Guomin Jiang
@ 2020-03-23 18:00     ` Michael D Kinney
  2020-03-23 21:54       ` Bret Barkelew
  0 siblings, 1 reply; 5+ messages in thread
From: Michael D Kinney @ 2020-03-23 18:00 UTC (permalink / raw)
  To: Jiang, Guomin, devel@edk2.groups.io, Zhang, Shenglei,
	newexplorerj@gmail.com, Kinney, Michael D
  Cc: Sean Brogan, Bret Barkelew

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

Mike

> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Sunday, March 22, 2020 11:08 PM
> To: devel@edk2.groups.io; Zhang, Shenglei
> <shenglei.zhang@intel.com>; newexplorerj@gmail.com
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
> Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: RE: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer
> before use.
> 
> Hi Michael, Sean, Bret,
> 
> Could you review the patch?
> 
> Thanks
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io
> [mailto:devel@edk2.groups.io] On Behalf Of
> > Zhang, Shenglei
> > Sent: Thursday, March 12, 2020 2:02 PM
> > To: devel@edk2.groups.io; newexplorerj@gmail.com
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
> Sean Brogan
> > <sean.brogan@microsoft.com>; Bret Barkelew
> > <Bret.Barkelew@microsoft.com>
> > Subject: Re: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib:
> > Check Suite pointer before use.
> >
> > Reviewed-by: Shenglei Zhang
> <shenglei.zhang@intel.com>
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io
> [mailto:devel@edk2.groups.io] On Behalf Of
> > > GuoMinJ
> > > Sent: Thursday, March 5, 2020 2:18 PM
> > > To: devel@edk2.groups.io
> > > Cc: GuoMinJ <newexplorerj@gmail.com>; Kinney,
> Michael D
> > > <michael.d.kinney@intel.com>; Sean Brogan
> > <sean.brogan@microsoft.com>;
> > > Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Subject: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib:
> > > Check Suite pointer before use.
> > >
> > > REF:
> https://bugzilla.tianocore.org/show_bug.cgi?id=2530
> > >
> > > The Suite pointer is used before check if it is
> valid, correct it to
> > > check the validation before use.
> > >
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> > > ---
> > >
> UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> | 6 +++---
> > >
> UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> | 2 +-
> > >  2 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > >
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > index fb247c59e7..b053e04959 100644
> > > ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > @@ -33,13 +33,13 @@ RunTestSuite (
> > >    UNIT_TEST             *Test;
> > >    UNIT_TEST_FRAMEWORK   *ParentFramework;
> > >
> > > -  TestEntry       = NULL;
> > > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> > > -
> > >    if (Suite == NULL) {
> > >      return EFI_INVALID_PARAMETER;
> > >    }
> > >
> > > +  TestEntry       = NULL;
> > > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > > >ParentFramework;
> > > +
> > >    DEBUG ((DEBUG_VERBOSE,
> > > "--------------------------------------------------
> ------
> > > -\n"));
> > >    DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE:
> %a\n", Suite->Title));
> > >    DEBUG ((DEBUG_VERBOSE,
> > > "--------------------------------------------------
> ------
> > > -\n"));
> > > diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > >
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > index fd15991ea4..b136992d99 100644
> > > ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > @@ -436,7 +436,6 @@ AddTestCase (
> > >
> > >    Status          = EFI_SUCCESS;
> > >    Suite           = (UNIT_TEST_SUITE
> *)SuiteHandle;
> > > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> > >
> > >    //
> > >    // First, let's check to make sure that our
> parameters look good.
> > > @@ -445,6 +444,7 @@ AddTestCase (
> > >      return EFI_INVALID_PARAMETER;
> > >    }
> > >
> > > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > > >ParentFramework;
> > >    //
> > >    // Create the new entry.
> > >    NewTestEntry = AllocateZeroPool (sizeof(
> UNIT_TEST_LIST_ENTRY ));
> > > --
> > > 2.17.1
> > >
> > >
> > >
> >
> >
> > 


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

* Re: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.
  2020-03-23 18:00     ` Michael D Kinney
@ 2020-03-23 21:54       ` Bret Barkelew
  0 siblings, 0 replies; 5+ messages in thread
From: Bret Barkelew @ 2020-03-23 21:54 UTC (permalink / raw)
  To: Kinney, Michael D, Jiang, Guomin, devel@edk2.groups.io,
	Zhang, Shenglei, newexplorerj@gmail.com
  Cc: Sean Brogan

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

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

- Bret

________________________________
From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Monday, March 23, 2020 11:00:42 AM
To: Jiang, Guomin <guomin.jiang@intel.com>; devel@edk2.groups.io <devel@edk2.groups.io>; Zhang, Shenglei <shenglei.zhang@intel.com>; newexplorerj@gmail.com <newexplorerj@gmail.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew <Bret.Barkelew@microsoft.com>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use.

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

Mike

> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Sunday, March 22, 2020 11:08 PM
> To: devel@edk2.groups.io; Zhang, Shenglei
> <shenglei.zhang@intel.com>; newexplorerj@gmail.com
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
> Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>
> Subject: RE: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer
> before use.
>
> Hi Michael, Sean, Bret,
>
> Could you review the patch?
>
> Thanks
>
> > -----Original Message-----
> > From: devel@edk2.groups.io
> [mailto:devel@edk2.groups.io] On Behalf Of
> > Zhang, Shenglei
> > Sent: Thursday, March 12, 2020 2:02 PM
> > To: devel@edk2.groups.io; newexplorerj@gmail.com
> > Cc: Kinney, Michael D <michael.d.kinney@intel.com>;
> Sean Brogan
> > <sean.brogan@microsoft.com>; Bret Barkelew
> > <Bret.Barkelew@microsoft.com>
> > Subject: Re: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib:
> > Check Suite pointer before use.
> >
> > Reviewed-by: Shenglei Zhang
> <shenglei.zhang@intel.com>
> >
> > > -----Original Message-----
> > > From: devel@edk2.groups.io
> [mailto:devel@edk2.groups.io] On Behalf Of
> > > GuoMinJ
> > > Sent: Thursday, March 5, 2020 2:18 PM
> > > To: devel@edk2.groups.io
> > > Cc: GuoMinJ <newexplorerj@gmail.com>; Kinney,
> Michael D
> > > <michael.d.kinney@intel.com>; Sean Brogan
> > <sean.brogan@microsoft.com>;
> > > Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Subject: [edk2-devel] [PATCH v2]
> UnitTestFrameworkPkg/UnitTestLib:
> > > Check Suite pointer before use.
> > >
> > > REF:
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2530&amp;data=02%7C01%7CBret.Barkelew%40microsoft.com%7Cd0071fa41da24d2a4bd208d7cf541d73%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637205832511879282&amp;sdata=q0NPXM7RP90QhMdusDZGd9nn1VtA4w%2FYxZbFu0vvnkI%3D&amp;reserved=0
> > >
> > > The Suite pointer is used before check if it is
> valid, correct it to
> > > check the validation before use.
> > >
> > > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > > Signed-off-by: GuoMinJ <newexplorerj@gmail.com>
> > > ---
> > >
> UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> | 6 +++---
> > >
> UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
> | 2 +-
> > >  2 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > >
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > index fb247c59e7..b053e04959 100644
> > > ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/RunTests.c
> > > @@ -33,13 +33,13 @@ RunTestSuite (
> > >    UNIT_TEST             *Test;
> > >    UNIT_TEST_FRAMEWORK   *ParentFramework;
> > >
> > > -  TestEntry       = NULL;
> > > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> > > -
> > >    if (Suite == NULL) {
> > >      return EFI_INVALID_PARAMETER;
> > >    }
> > >
> > > +  TestEntry       = NULL;
> > > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > > >ParentFramework;
> > > +
> > >    DEBUG ((DEBUG_VERBOSE,
> > > "--------------------------------------------------
> ------
> > > -\n"));
> > >    DEBUG ((DEBUG_VERBOSE, "RUNNING TEST SUITE:
> %a\n", Suite->Title));
> > >    DEBUG ((DEBUG_VERBOSE,
> > > "--------------------------------------------------
> ------
> > > -\n"));
> > > diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > >
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > index fd15991ea4..b136992d99 100644
> > > ---
> a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > +++
> b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.
> c
> > > @@ -436,7 +436,6 @@ AddTestCase (
> > >
> > >    Status          = EFI_SUCCESS;
> > >    Suite           = (UNIT_TEST_SUITE
> *)SuiteHandle;
> > > -  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > >ParentFramework;
> > >
> > >    //
> > >    // First, let's check to make sure that our
> parameters look good.
> > > @@ -445,6 +444,7 @@ AddTestCase (
> > >      return EFI_INVALID_PARAMETER;
> > >    }
> > >
> > > +  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite-
> > > >ParentFramework;
> > >    //
> > >    // Create the new entry.
> > >    NewTestEntry = AllocateZeroPool (sizeof(
> UNIT_TEST_LIST_ENTRY ));
> > > --
> > > 2.17.1
> > >
> > >
> > >
> >
> >
> > 


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

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

end of thread, other threads:[~2020-03-23 21:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-05  6:17 [PATCH v2] UnitTestFrameworkPkg/UnitTestLib: Check Suite pointer before use GuoMinJ
2020-03-12  6:02 ` [edk2-devel] " Zhang, Shenglei
2020-03-23  6:08   ` Guomin Jiang
2020-03-23 18:00     ` Michael D Kinney
2020-03-23 21:54       ` Bret Barkelew

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