@@ -19,7 +19,7 @@ import semmle.code.cpp.valuenumbering.GlobalValueNumbering
19
19
* For example: `if(intA>0 & intA<10 & charBuf&myFunc(charBuf[intA]))`.
20
20
* In this case, the function will be called in any case, and even the sequence of the call is not guaranteed.
21
21
*/
22
- class DangerousBitOperations extends Expr {
22
+ class DangerousBitOperations extends BinaryBitwiseOperation {
23
23
FunctionCall bfc ;
24
24
25
25
/**
@@ -28,16 +28,16 @@ class DangerousBitOperations extends Expr {
28
28
* The use of shifts and bitwise operations on any element of an expression indicates a conscious use of the bitwise operator.
29
29
*/
30
30
DangerousBitOperations ( ) {
31
- bfc = this .( BinaryBitwiseOperation ) . getRightOperand ( ) and
31
+ bfc = this .getRightOperand ( ) and
32
32
not this .getParent * ( ) instanceof Assignment and
33
33
not this .getParent * ( ) instanceof Initializer and
34
34
not this .getParent * ( ) instanceof ReturnStmt and
35
35
not this .getParent * ( ) instanceof EqualityOperation and
36
36
not this .getParent * ( ) instanceof UnaryLogicalOperation and
37
37
not this .getParent * ( ) instanceof BinaryLogicalOperation and
38
- not this .( BinaryBitwiseOperation ) . getAChild * ( ) instanceof BitwiseXorExpr and
39
- not this .( BinaryBitwiseOperation ) . getAChild * ( ) instanceof LShiftExpr and
40
- not this .( BinaryBitwiseOperation ) . getAChild * ( ) instanceof RShiftExpr
38
+ not this .getAChild * ( ) instanceof BitwiseXorExpr and
39
+ not this .getAChild * ( ) instanceof LShiftExpr and
40
+ not this .getAChild * ( ) instanceof RShiftExpr
41
41
}
42
42
43
43
/** Holds when part of a bit expression is used in a logical operation. */
@@ -60,14 +60,14 @@ class DangerousBitOperations extends Expr {
60
60
61
61
/** Holds when the bit expression contains both arguments and a function call. */
62
62
predicate dangerousArgumentChecking ( ) {
63
- not this .( BinaryBitwiseOperation ) . getLeftOperand ( ) instanceof Call and
64
- globalValueNumber ( this .( BinaryBitwiseOperation ) . getLeftOperand ( ) .getAChild * ( ) ) =
63
+ not this .getLeftOperand ( ) instanceof Call and
64
+ globalValueNumber ( this .getLeftOperand ( ) .getAChild * ( ) ) =
65
65
globalValueNumber ( bfc .getAnArgument ( ) )
66
66
}
67
67
68
68
/** Holds when function calls are present in the bit expression. */
69
69
predicate functionCallsInBitsExpression ( ) {
70
- this .( BinaryBitwiseOperation ) . getLeftOperand ( ) .getAChild * ( ) instanceof FunctionCall
70
+ this .getLeftOperand ( ) .getAChild * ( ) instanceof FunctionCall
71
71
}
72
72
}
73
73
0 commit comments