Critical data member is not private
Description
This defect occurs when you declare a critical nonstatic data member of a class to be
public
. By default, Polyspace® assumes that no data member is critical. Specify the critical data members in
your code by using the code behavior CRITICAL_DATA
. See Specifying Critical Data Members. If you do not specify
any critical data members, Polyspace raises a warning during the analysis.
Risk
Declaring the critical data members as public
allows the clients of a
class to modify critical data members. You can inadvertently introduce vulnerabilities when
critical data members are public. The vulnerabilities of such code are difficult to find and
time-consuming to fix.
Fix
To fix this defect, determine which data members are critical and declare them as
private
or protected
.
Extend Checker
This defect checker requires a list of critical data members to be externally specified. Even if you specify the checker using the option Find defects (-checkers)
, it is not enabled unless you also specify a list of critical data members. See Modify Bug Finder Checkers Through Code Behavior Specifications.
Examples
Result Information
Group: Security |
Language: C++ |
Default: Off |
Command-Line Syntax:
CRITICAL_DATA_MEMBER_DECLARED_PUBLIC |
Impact: High |
Version History
Introduced in R2022aSee Also
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)