JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
A call to memcmp() or bcmp() specifies a length parameter that exceeds the length of one or both memory parameters.
When READ_PAST_NTERM_CONSERVATIVE_CHECK=Yes, warnings of this class are only issued if both memory parameters are arrays having essentially char type. This behavior matches the technical definition of Misra2012:21.14.
| クラス名 | Read Past Null Terminator | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Read Past Null Terminator | |||||||||||||||
| クラス分類 | 信頼性 (reliability) | |||||||||||||||
| ニーモニック | MISC.MEM.RPNT | |||||||||||||||
| カテゴリー |
|
|||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Read Past Null Terminator" |
#include <string.h>
#include <stdlib.h>
char buffer1[ 12 ];
char buffer2[ 12 ];
int misc_mem_rpnt_charstar ( void ){
(void) strcpy(buffer1, "abc");
(void) strcpy(buffer2, "abc");
if (memcmp ((void *) buffer1,
(void *) buffer2,
sizeof(buffer1)) != 0) { /* 'Read Past Null Terminator' warning issued here */
return 1;
}
return memcmp((void *) buffer1,
(void *) buffer2,
(unsigned int) 3); /* ok: only comparing up to null terminator */
}
int misc_mem_rpnt_voidstar( void ){
void * s1 = buffer1; /* not an array of essentially char type */
void * s2 = buffer2; /* not an array of essentially char type */
(void) strcpy(s1, "abc");
(void) strcpy(s2, "abc");
if (memcmp(s1,
s2,
sizeof(buffer1)) != 0){ /* 'Read Past Null Terminator' warning issued here
* only if READ_PAST_NTERM_CONSERVATIVE_CHECK=No */
return 1;
}
return 0;
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.