@@ -56,14 +56,14 @@ private predicate isIncorrectIntegerConversion(int sourceBitSize, int sinkBitSiz
56
56
* integer types, which could cause unexpected values.
57
57
*/
58
58
class ConversionWithoutBoundsCheckConfig extends TaintTracking:: Configuration {
59
- boolean sourceIsSigned ;
59
+ boolean sinkIsSigned ;
60
60
int sourceBitSize ;
61
61
int sinkBitSize ;
62
62
63
63
ConversionWithoutBoundsCheckConfig ( ) {
64
- sourceIsSigned in [ true , false ] and
64
+ sinkIsSigned in [ true , false ] and
65
65
isIncorrectIntegerConversion ( sourceBitSize , sinkBitSize ) and
66
- this = "ConversionWithoutBoundsCheckConfig" + sourceBitSize + sourceIsSigned + sinkBitSize
66
+ this = "ConversionWithoutBoundsCheckConfig" + sourceBitSize + sinkIsSigned + sinkBitSize
67
67
}
68
68
69
69
/** Gets the bit size of the source. */
@@ -75,11 +75,6 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
75
75
|
76
76
c .getTarget ( ) = ip and source = c .getResult ( 0 )
77
77
|
78
- (
79
- if ip .getResultType ( 0 ) instanceof SignedIntegerType
80
- then sourceIsSigned = true
81
- else sourceIsSigned = false
82
- ) and
83
78
(
84
79
apparentBitSize = ip .getTargetBitSize ( )
85
80
or
@@ -112,10 +107,13 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
112
107
predicate isSinkWithBitSize ( DataFlow:: TypeCastNode sink , int bitSize ) {
113
108
sink .asExpr ( ) instanceof ConversionExpr and
114
109
exists ( IntegerType integerType | sink .getResultType ( ) .getUnderlyingType ( ) = integerType |
115
- bitSize = integerType .getSize ( )
116
- or
117
- not exists ( integerType .getSize ( ) ) and
118
- bitSize = getIntTypeBitSize ( sink .getFile ( ) )
110
+ (
111
+ bitSize = integerType .getSize ( )
112
+ or
113
+ not exists ( integerType .getSize ( ) ) and
114
+ bitSize = getIntTypeBitSize ( sink .getFile ( ) )
115
+ ) and
116
+ if integerType instanceof SignedIntegerType then sinkIsSigned = true else sinkIsSigned = false
119
117
) and
120
118
not exists ( ShrExpr shrExpr |
121
119
shrExpr .getLeftOperand ( ) .getGlobalValueNumber ( ) =
@@ -134,7 +132,7 @@ class ConversionWithoutBoundsCheckConfig extends TaintTracking::Configuration {
134
132
if sinkBitSize != 0 then bitSize = sinkBitSize else bitSize = 32
135
133
|
136
134
node = DataFlow:: BarrierGuard< upperBoundCheckGuard / 3 > :: getABarrierNodeForGuard ( g ) and
137
- g .isBoundFor ( bitSize , sourceIsSigned )
135
+ g .isBoundFor ( bitSize , sinkIsSigned )
138
136
)
139
137
}
140
138
0 commit comments