Function appears in a blacklist of forbidden functions
This defect occurs when you use a function that appears in a blacklist of forbidden functions. To create the blacklist:
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\cxx
<function name="funcname" behavior="FORBIDDEN_FUNC"/>
funcname is the name of the function
you want to blacklist.Specify this XML file as argument for the option -code-behavior-specifications.
Even if you enable this checker using the option Find
defects (-checkers), unless you specify a blacklist of functions, this checker
stays disabled.
A function might be blacklisted 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 blacklist functions that are not explicitly checked by existing checkers
such as Use of dangerous standard function or
Use 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.
Replace the blacklisted function with an approved function.
When rolling out this checker to a group, project or organization, create a list of blacklist functions and their replacements so that results reviewers can consult the list and make appropriate replacements.
| Group: Good practice |
| Language: C | C++ |
| Default: Off |
Command-Line Syntax:
FORBIDDEN_FUNC |
| Impact: Low |