File tree Expand file tree Collapse file tree
cpp/ql/src/semmle/code/cpp/ir
implementation/raw/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -335,6 +335,12 @@ private Element adjustedSink(DataFlow::Node sink) {
335335 // For compatibility, send flow into a `NotExpr` even if it's part of a
336336 // short-circuiting condition and thus might get skipped.
337337 result .( NotExpr ) .getOperand ( ) = sink .asExpr ( )
338+ or
339+ // Taint `e--` and `e++` when `e` is tainted.
340+ exists ( PostfixCrementOperation crement |
341+ crement .getAnOperand ( ) = sink .asExpr ( ) and
342+ result = crement
343+ )
338344}
339345
340346predicate tainted ( Expr source , Element tainted ) {
Original file line number Diff line number Diff line change @@ -2469,6 +2469,9 @@ predicate exprNeedsCopyIfNotLoaded(Expr expr) {
24692469 expr instanceof PrefixCrementOperation and
24702470 not expr .isPRValueCategory ( ) // is C++
24712471 or
2472+ // Because the load is on the `e` in `e++`.
2473+ expr instanceof PostfixCrementOperation
2474+ or
24722475 expr instanceof PointerDereferenceExpr
24732476 or
24742477 expr instanceof AddressOfExpr
@@ -2486,12 +2489,6 @@ predicate exprNeedsCopyIfNotLoaded(Expr expr) {
24862489 // TODO: simplify TranslatedStmtExpr too
24872490 ) and
24882491 not exprImmediatelyDiscarded ( expr )
2489- or
2490- // For certain expressions we want to keep the CopyValue instruction even though the result might
2491- // not be needed, as we otherwise cannot get back the original expression. For now the only such
2492- // expressions we have encountered are `e++` and `e--`.
2493- // Because the load is on the `e` in `e++`.
2494- expr instanceof PostfixCrementOperation
24952492}
24962493
24972494/**
You can’t perform that action at this time.
0 commit comments