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 |
チェックされていない乗算によるメモリ割り当てサイズの計算は、 整数オーバーフローを起こし予期せず割り当てブロックサイズが小さくなる危険性があります。
一般的に、 割り当てサイズの乗算オーバーフロー (Multiplication Overflow of Allocation Size) の部分集合となります。 但し、C++ の new[] 内で暗黙的に乗算される場合を除きます(この場合は、割り当てサイズの整数オーバーフローを引き起こしますが、割り当てサイズの乗算オーバーフローは引き起こしません)。
| クラス名 | Integer Overflow of Allocation Size | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | 割り当てサイズの整数オーバーフロー | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| クラス分類 | セキュリティ (security) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ニーモニック | ALLOC.SIZE.IOFLOW | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Integer Overflow of Allocation Size" |
このワーニングを避けるためには、 割り当てサイズの計算値を使用する前に全ての乗算結果をチェックしてください。
#include <cstdlib>
void ioflow(int x, int y, int z){
int s;
char *p;
p = (char *) malloc(x * y); /* 'Integer Overflow of Allocation Size' warning issued here */
/* When enabled, 'Multiplication Overflow of Allocation Size' warning also issued here */
if (!p){return;} else {free(p);}
s = x * y;
p = (char *) malloc(s); /* 'Integer Overflow of Allocation Size' warning issued here */
if (!p){return;} else {free(p);}
p = new char[x * y]; /* 'Integer Overflow of Allocation Size' warning issued here */
delete[] p;
s = y * z;
if (s / y == z){
p = (char *) malloc(s + 1); /* ok: multiplication result was checked */
if (!p){return;} else {free(p);}
}
if ( (y*z) / y == z){
p = (char *) malloc(y*z + 1); /* 'Integer Overflow of Allocation Size' warning issued here
* - the multiplication operation inside the malloc() argument was not checked
*/
if (!p){return;} else {free(p);}
}
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.