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 |
The value returned by one of the following functions is treated as if it is not a pointer to const-qualified type.
| クラス名 | Returned Pointer Not Treated as const | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Returned Pointer Not Treated as const | ||||||||||||||||||
| クラス分類 | セキュリティ (security) | ||||||||||||||||||
| ニーモニック | LANG.STRUCT.RPNTC | ||||||||||||||||||
| カテゴリー |
|
||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Returned Pointer Not Treated as const" |
#include <stdlib.h> #include <string.h> /* The value of an environment variable can change, so getenv(name) * for fixed name may have different values at different program * points. */ char * lang_struct_rpntc(char *name, char str[128]){ char *c; const char *cc; c = getenv(name); /* 'Returned Pointer Not Treated as const' warning issued here. * The code does not subsequently mutate *c, but future changes could * introduce a mutation without causing compilation errors. * Use a const-qualified variable to prevent this. */ if (!c){return NULL;} cc = getenv(name); /* ok: const-qualified pointer type */ if (!cc){return NULL;} getenv(name)[0] = 'X'; /* 'Returned Pointer Not Treated as const' warning issued here * ('Null Pointer Dereference' warning also issued: getenv() may return NULL) */ return strncpy(str, getenv(name), 127); /* no 'Returned Pointer Not Treated as const' warning * - strcpy type signature is * char *strncpy (char *, const char *, size_t) */ /* ('Null Pointer Dereference' warning issued: getenv() may return NULL) */ }
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.