Skip to content

Commit 25571ec

Browse files
committed
Convert FIO44-C to the new dataflow library
1 parent 1309e18 commit 25571ec

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

c/cert/src/rules/FIO44-C/OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import cpp
1919
import codingstandards.c.cert
20-
import semmle.code.cpp.dataflow.DataFlow
20+
import semmle.code.cpp.dataflow.new.DataFlow
2121

2222
class FgetposCall extends FunctionCall {
2323
FgetposCall() { this.getTarget().hasGlobalOrStdName("fgetpos") }
@@ -30,12 +30,12 @@ class FsetposCall extends FunctionCall {
3030
module FposDFConfig implements DataFlow::ConfigSig {
3131
predicate isSource(DataFlow::Node source) {
3232
// source must be the second parameter of a FgetposCall call
33-
source = DataFlow::definitionByReferenceNodeFromArgument(any(FgetposCall c).getArgument(1))
33+
source.asDefiningArgument() = any(FgetposCall c).getArgument(1)
3434
}
3535

3636
predicate isSink(DataFlow::Node sink) {
3737
// sink must be the second parameter of a FsetposCall call
38-
sink.asExpr() = any(FsetposCall c).getArgument(1)
38+
sink.asIndirectExpr() = any(FsetposCall c).getArgument(1)
3939
}
4040
}
4141

@@ -45,6 +45,6 @@ from FsetposCall fsetpos
4545
where
4646
not isExcluded(fsetpos.getArgument(1),
4747
IO2Package::onlyUseValuesForFsetposThatAreReturnedFromFgetposQuery()) and
48-
not FposDFFlow::flowToExpr(fsetpos.getArgument(1))
48+
not exists(DataFlow::Node n | n.asIndirectExpr() = fsetpos.getArgument(1) | FposDFFlow::flowTo(n))
4949
select fsetpos.getArgument(1),
5050
"The position argument of a call to `fsetpos()` should be obtained from a call to `fgetpos()`."
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql:30,32-40)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql:31,22-30)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql:33,14-22)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql:36,20-28)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (OnlyUseValuesForFsetposThatAreReturnedFromFgetpos.ql:42,21-29)
61
| test.c:7:24:7:30 | & ... | The position argument of a call to `fsetpos()` should be obtained from a call to `fgetpos()`. |
72
| test.c:33:24:33:30 | & ... | The position argument of a call to `fsetpos()` should be obtained from a call to `fgetpos()`. |

0 commit comments

Comments
 (0)