Reporting Issues
Bug 2530 - UnitTestFrameworkPkg: Suspicious dereference of pointer Suite before null check
Summary: UnitTestFrameworkPkg: Suspicious dereference of pointer Suite before null check
Status: RESOLVED FIXED
Alias: None
Product: EDK2
Classification: Unclassified
Component: Code (show other bugs)
Version: Current
Hardware: All All
: Normal normal
Assignee: guomin.jiang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-17 05:31 UTC by shenglei.zhang
Modified: 2020-06-03 16:38 UTC (History)
3 users (show)

See Also:
EDK II Code First industry standard specifications: ---
Branch URL:
Release(s) the issue is observed:
The OS the target platform is running: ---
Package: UnitTestFrameworkPkg
Release(s) the issues must be fixed:
Tianocore documents:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shenglei.zhang 2020-02-17 05:31:44 UTC
UnitTestFrameworkPkg\Library\UnitTestLib\RunTests.c    line 37
Suspicious dereference of pointer 'Suite' before NULL check at line 39

UnitTestFrameworkPkg\Library\UnitTestLib\RunTestsCmocka.c   line 439
Suspicious dereference of pointer 'Suite' before NULL check at line 444
Comment 1 shenglei.zhang 2020-02-17 05:32:45 UTC
Assigned to Liming
Comment 2 nobody 2020-02-17 20:14:06 UTC
Guomin will check it.
Comment 3 shenglei.zhang 2020-03-04 02:54:04 UTC
(In reply to shenglei.zhang from comment #0)
> UnitTestFrameworkPkg\Library\UnitTestLib\RunTests.c    line 37
> Suspicious dereference of pointer 'Suite' before NULL check at line 39
> 
> UnitTestFrameworkPkg\Library\UnitTestLib\RunTestsCmocka.c   line 439
> Suspicious dereference of pointer 'Suite' before NULL check at line 444

RunTestsCmocka.c should be UnitTestLib.c.
Comment 4 newexplorerj 2020-03-04 05:30:46 UTC
UnitTestLib.c seem ok in the newest master, could you double check it.
Comment 5 shenglei.zhang 2020-03-04 22:18:36 UTC
(In reply to newexplorerj from comment #4)
> UnitTestLib.c seem ok in the newest master, could you double check it.

I think the issue still exists.
We can fix this issue through below change.

  if ((Suite == NULL) || (Description == NULL) || (Name == NULL) || (Function 
  == NULL)) {
    return EFI_INVALID_PARAMETER;
  }

  ParentFramework = (UNIT_TEST_FRAMEWORK *)Suite->ParentFramework;
Comment 6 newexplorerj 2020-03-05 01:21:42 UTC
Change subject and add missing change, post patch v2 at https://edk2.groups.io/g/devel/message/55476.