Skip to content

Commit fd9c1d3

Browse files
committed
Remove argument that is always one value
1 parent cf0411e commit fd9c1d3

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

go/ql/lib/semmle/go/security/IncorrectIntegerConversionLib.qll

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ private class MaxValueState extends TMaxValueState {
210210
* we should use 32 bits, because that will find results that only exist on
211211
* 32-bit architectures.
212212
*/
213-
bindingset[default]
214-
int getSinkBitSize(int default) {
215-
if this = TMkMaxValueState(_, TMk64Bit()) then result = 64 else result = default
213+
int getSinkBitSize() {
214+
if this = TMkMaxValueState(_, TMk64Bit()) then result = 64 else result = 32
216215
}
217216

218217
/** Gets a textual representation of this element. */
@@ -341,9 +340,7 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
341340
}
342341

343342
override predicate barrierFor(MaxValueState flowstate) {
344-
// Use a default value of 32 for `MaxValueState.getSinkBitSize` because
345-
// this will find results that only exist on 32-bit architectures.
346-
g.isBoundFor(flowstate.getBitSize(), flowstate.getSinkBitSize(32))
343+
g.isBoundFor(flowstate.getBitSize(), flowstate.getSinkBitSize())
347344
}
348345

349346
override MaxValueState transform(MaxValueState state) {
@@ -352,9 +349,7 @@ class UpperBoundCheck extends BarrierFlowStateTransformer {
352349
max(int bitsize |
353350
bitsize = validBitSize() and
354351
bitsize < state.getBitSize() and
355-
// Use a default value of 32 for `MaxValueState.getSinkBitSize` because
356-
// this will find results that only exist on 32-bit architectures.
357-
not g.isBoundFor(bitsize, state.getSinkBitSize(32))
352+
not g.isBoundFor(bitsize, state.getSinkBitSize())
358353
) and
359354
(
360355
result.getArchitectureBitSize() = state.getArchitectureBitSize()
@@ -428,9 +423,7 @@ private module ConversionWithoutBoundsCheckConfig implements DataFlow::StateConf
428423
additional predicate isSink2(DataFlow::TypeCastNode sink, FlowState state) {
429424
sink.asExpr() instanceof ConversionExpr and
430425
exists(int architectureBitSize, IntegerType integerType, int sinkBitsize, boolean sinkIsSigned |
431-
// Use a default value of 32 for `MaxValueState.getSinkBitSize` because
432-
// this will find results that only exist on 32-bit architectures.
433-
architectureBitSize = getIntTypeBitSize(sink.getFile(), state.getSinkBitSize(32)) and
426+
architectureBitSize = getIntTypeBitSize(sink.getFile(), state.getSinkBitSize()) and
434427
not (state.getArchitectureBitSize() = 32 and architectureBitSize = 64) and
435428
sink.getResultType().getUnderlyingType() = integerType and
436429
(

0 commit comments

Comments
 (0)