C and C++ Binaries


LANG.ARITH.NEGSHIFT : 負の値によるシフト

要旨

data << shift_amount

または

data >> shift_amount

にて、負の値となる shift_amount によってシフトされています。

プロパティ

クラス名 Negative Shift Amount
日本語クラス名 負の値によるシフト
クラス分類 セキュリティ (security)
ニーモニック LANG.ARITH.NEGSHIFT
カテゴリー
MisraC2023 MisraC2023:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC2023:12.2 The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
Misra2012 Misra2012:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  Misra2012:12.2 The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
Misra2004 Misra2004:12.8 The right-hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left-hand operand
AUTOSARC++14 AUTOSARC++14:M5-8-1 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.
MisraC++2008 MisraC++2008:5-8-1 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.
MisraC++2023 MisraC++2023:4.1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC++2023:7.0.4 The operands of bitwise operators and shift operators shall be appropriate
CWE CWE:758 Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
  CWE:1335 Incorrect Bitwise Shift of Integer
CERT-C CERT-C:INT34-C Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand
JSF++ JSF++:164 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left-hand operand (inclusive).
DISA-3r10 DISA-3r10:V-16808 The designer will ensure the application is not vulnerable to integer arithmetic issues.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Negative Shift Amount"

int negshift(void){
    int a = 50;
    int b = a << -2;   /* 'Negative Shift Amount' warning issued here */
    return a+b;
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。