MISRA C++:2008 Rule 18-0-5
The unbounded functions of library <cstring> shall not be used
説明
The unbounded functions of library <cstring> shall not be used. 1
根拠
ライブラリ <cstring> に含まれている非有界の関数は、バッファーに対して読み取りや書き込みを行う際に、バッファーの範囲をチェックしません。そのため、バッファーの末尾より先にアクセスすることになります。これは未定義の動作です。バッファーの末尾より先を読み取る関数には、strcpy、strcmp、strcat、strchr、strspn、strcspn、strpbrk、strrchr、strstr、strtok、strlen があります。
Polyspace 実装
コード内で以下のいずれかの名前が使用されている場合、Polyspace® は違反を報告します。
strcpystrcmpstrcatstrchrstrspnstrcspnstrpbrkstrrchrstrstrstrtokstrlen
トラブルシューティング
ルール違反が想定されるものの、Polyspace から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
| グループ: Language Support Library |
| カテゴリ: 必要 |
バージョン履歴
R2013b で導入
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.