Skip to content

Commit 9f811b2

Browse files
authored
C++: remove unused variables and fix tests
1 parent 013216d commit 9f811b2

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

cpp/ql/lib/semmle/code/cpp/commons/Printf.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ class FormatLiteral extends Literal {
11851185
1 + lengthInBase10(2.pow(this.getIntegralDisplayType(n).getSize() * 8 - 1)) and
11861186
// The second case uses range analysis to deduce a length that's shorter than the length
11871187
// of the number -2^31.
1188-
exists(Expr arg, float lower, float upper, float typeLower, float typeUpper |
1188+
exists(Expr arg, float lower, float upper |
11891189
arg = this.getUse().getConversionArgument(n).getFullyConverted() and
11901190
lower = lowerBound(arg) and
11911191
upper = upperBound(arg)
@@ -1217,12 +1217,10 @@ class FormatLiteral extends Literal {
12171217
typeBasedBound = lengthInBase10(2.pow(this.getIntegralDisplayType(n).getSize() * 8) - 1) and
12181218
// The second case uses range analysis to deduce a length that's shorter than
12191219
// the length of the number 2^31 - 1.
1220-
exists(Expr arg, float lower, float upper, float typeLower, float typeUpper |
1220+
exists(Expr arg, float lower, float upper |
12211221
arg = this.getUse().getConversionArgument(n).getFullyConverted() and
12221222
lower = lowerBound(arg) and
1223-
upper = upperBound(arg) and
1224-
typeLower = exprMinVal(arg) and
1225-
typeUpper = exprMaxVal(arg)
1223+
upper = upperBound(arg)
12261224
|
12271225
valueBasedBound =
12281226
lengthInBase10(max(float cand |

cpp/ql/test/query-tests/Security/CWE/CWE-242/semmle/tests/OverrunWrite.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
| tests.cpp:315:2:315:8 | call to sprintf | This 'call to sprintf' operation requires 11 bytes but the destination is only 4 bytes. |
44
| tests.cpp:316:2:316:8 | call to sprintf | This 'call to sprintf' operation requires 11 bytes but the destination is only 4 bytes. |
55
| tests.cpp:327:2:327:8 | call to sprintf | This 'call to sprintf' operation requires 12 bytes but the destination is only 4 bytes. |
6+
| tests.cpp:329:3:329:9 | call to sprintf | This 'call to sprintf' operation requires 12 bytes but the destination is only 4 bytes. |

cpp/ql/test/query-tests/Security/CWE/CWE-242/semmle/tests/VeryLikelyOverrunWrite.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
| tests.cpp:308:3:308:9 | call to sprintf | This 'call to sprintf' operation requires 9 bytes but the destination is only 8 bytes. |
44
| tests.cpp:321:2:321:8 | call to sprintf | This 'call to sprintf' operation requires 11 bytes but the destination is only 4 bytes. |
55
| tests.cpp:324:3:324:9 | call to sprintf | This 'call to sprintf' operation requires 11 bytes but the destination is only 4 bytes. |
6-
| tests.cpp:329:3:329:9 | call to sprintf | This 'call to sprintf' operation requires 12 bytes but the destination is only 4 bytes. |
76
| tests.cpp:341:2:341:8 | call to sprintf | This 'call to sprintf' operation requires 3 bytes but the destination is only 2 bytes. |
87
| tests.cpp:343:2:343:8 | call to sprintf | This 'call to sprintf' operation requires 3 bytes but the destination is only 2 bytes. |
98
| tests.cpp:345:2:345:8 | call to sprintf | This 'call to sprintf' operation requires 11 bytes but the destination is only 2 bytes. |

0 commit comments

Comments
 (0)