Skip to content

Commit 0508092

Browse files
committed
C++: Don't use converted expressions in 'LeapYear.qll'.
1 parent b03054b commit 0508092

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
296296
}
297297

298298
override predicate isSource(DataFlow::Node source) {
299-
exists(Operation op | op = source.asConvertedExpr() |
299+
exists(Operation op | op = source.asExpr() |
300300
op.getAChild*().getValue().toInt() = 365 and
301301
(
302302
not op.getParent() instanceof Expr or
@@ -321,7 +321,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
321321

322322
override predicate isSink(DataFlow::Node sink) {
323323
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
324-
aexpr.getRValue() = sink.asConvertedExpr()
324+
aexpr.getRValue() = sink.asExpr()
325325
|
326326
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
327327
fa.getQualifier().getUnderlyingType() = dds and
@@ -336,7 +336,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
336336
*/
337337
private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::ConfigSig {
338338
predicate isSource(DataFlow::Node source) {
339-
exists(Operation op | op = source.asConvertedExpr() |
339+
exists(Operation op | op = source.asExpr() |
340340
op.getAChild*().getValue().toInt() = 365 and
341341
(
342342
not op.getParent() instanceof Expr or
@@ -361,7 +361,7 @@ private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::C
361361

362362
predicate isSink(DataFlow::Node sink) {
363363
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
364-
aexpr.getRValue() = sink.asConvertedExpr()
364+
aexpr.getRValue() = sink.asExpr()
365365
|
366366
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
367367
fa.getQualifier().getUnderlyingType() = dds and
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
| test.cpp:173:29:173:51 | ... & ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... |
2+
| test.cpp:173:29:173:51 | ... & ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:170:16:170:47 | ... * ... | ... * ... |
3+
| test.cpp:174:30:174:45 | ... >> ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:170:2:170:47 | ... += ... | ... += ... |
4+
| test.cpp:174:30:174:45 | ... >> ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:170:16:170:47 | ... * ... | ... * ... |
15
| test.cpp:193:15:193:24 | ... / ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:193:15:193:24 | ... / ... | ... / ... |
6+
| test.cpp:217:29:217:51 | ... & ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:214:2:214:47 | ... += ... | ... += ... |
7+
| test.cpp:217:29:217:51 | ... & ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:214:16:214:47 | ... * ... | ... * ... |
8+
| test.cpp:218:30:218:45 | ... >> ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:214:2:214:47 | ... += ... | ... += ... |
9+
| test.cpp:218:30:218:45 | ... >> ... | An arithmetic operation $@ that uses a constant value of 365 ends up modifying this date/time, without considering leap year scenarios. | test.cpp:214:16:214:47 | ... * ... | ... * ... |

0 commit comments

Comments
 (0)