Use of a forbidden function
Description
This defect occurs when you use a function that appears in a blocklist of forbidden functions. To create the blocklist:
List functions in an XML file in a specific syntax.
Copy the template file
code-behavior-specifications-template.xml
from the folder
to a writable location and modify the file. Enter each function in the file using the following syntax after existing similar entries:polyspaceroot
\polyspace\verifier\cxxwhere<function name="funcname"> <behavior name="FORBIDDEN_FUNC"/> </function>
is the name of the function you want to block.funcname
Specify this XML file as argument for the option
-code-behavior-specifications
. See Flag Deprecated or Unsafe Functions, Keywords, or Macros Using Bug Finder Checkers.
Risk
A function might be blocked for one of these reasons:
The function can lead to many situations where the behavior is undefined leading to security vulnerabilities, and a more secure function exists.
You can forbid functions that are not explicitly checked by existing checkers such as
Use of dangerous standard function
orUse of obsolete standard function
.The function is being deprecated as part of a migration, for instance, from C++98 to C++11.
As part of a migration, you can make a list of functions that need to be replaced and use this checker to identify their use.
Fix
Replace the blocked function with an allowed function.
When rolling out this checker to a group, project or organization, create a list of blocked functions and their replacements so that results reviewers can consult the list and make appropriate replacements.
Extend Checker
This defect checker requires a blocklist of functions to be specified. Even if you specify the checker using the option Find defects (-checkers)
, it is not enabled unless you also specify the blocklist. See Flag Deprecated or Unsafe Functions, Keywords, or Macros Using Bug Finder Checkers.
Examples
Result Information
Group: Good practice |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
FORBIDDEN_FUNC |
Impact: Low |
Version History
Introduced in R2020a
See Also
Find defects
(-checkers)
| -code-behavior-specifications
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)
- Flag Deprecated or Unsafe Functions, Keywords, or Macros Using Bug Finder Checkers