Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit a669fa4

Browse files
committed
Do not flow taint through remainder expressions
If the tainted operand is the first operand then it is being bounded above by the remainder expression. If it is the second operand then
1 parent aed3ef4 commit a669fa4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ql/src/semmle/go/security/AllocationSizeOverflowCustomizations.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ module AllocationSizeOverflow {
175175

176176
/**
177177
* Holds if the value of `pred` can flow into `succ` in one step, either through a call to `len`
178-
* or through an arithmetic operation.
178+
* or through an arithmetic operation (other than remainder).
179179
*/
180180
predicate additionalStep(DataFlow::Node pred, DataFlow::Node succ) {
181181
exists(DataFlow::CallNode c |
@@ -184,7 +184,8 @@ module AllocationSizeOverflow {
184184
succ = c
185185
)
186186
or
187-
succ.asExpr().(ArithmeticExpr).getAnOperand() = pred.asExpr()
187+
succ.asExpr().(ArithmeticExpr).getAnOperand() = pred.asExpr() and
188+
not succ.asExpr() instanceof RemExpr
188189
}
189190

190191
/**

0 commit comments

Comments
 (0)