Invalid use of standard library string routine
Standard library string function called with invalid arguments
Description
This defect occurs when a string library function is called with invalid arguments.
Risk
The risk depends on the type of invalid arguments. For instance, using the
strcpy
function with a source argument larger than the
destination argument can result in buffer overflows.
Fix
The fix depends on the standard library
function involved in the defect. In some cases, you can constrain the function
arguments before the function call. For instance, if the strcpy
function:
char * strcpy(char * destination, const char* source)
strcpy
.
In some cases, you can use an alternative function to avoid the error. For instance,
instead of strcpy
, you can use strncpy
to
control the number of bytes copied.See examples of fixes below.
If you do not want to fix the issue, add comments to your result or code to avoid another review. See:
Address Results in Polyspace User Interface Through Bug Fixes or Justifications if you review results in the Polyspace user interface.
Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access) if you review results in a web browser.
Annotate Code and Hide Known or Acceptable Results if you review results in an IDE.
Examples
Result Information
Group: Static memory |
Language: C | C++ |
Default: On |
Command-Line Syntax: STR_STD_LIB |
Impact: High |
Version History
Introduced in R2013bSee Also
Find defects (-checkers)
| Invalid use of standard library memory routine
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)