Skip to content

Commit c159604

Browse files
committed
Convert RULE-17-5 to the new dataflow library
1 parent bd434ed commit c159604

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

c/misra/src/rules/RULE-17-5/ArrayFunctionArgumentNumberOfElements.ql

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

1515
import cpp
1616
import codingstandards.c.misra
17-
import semmle.code.cpp.dataflow.DataFlow
17+
import semmle.code.cpp.dataflow.new.DataFlow
1818

1919
/**
2020
* Models a function parameter of type array with specified size
@@ -49,7 +49,7 @@ module SmallArrayConfig implements DataFlow::ConfigSig {
4949
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof ArrayAggregateLiteral }
5050

5151
predicate isSink(DataFlow::Node sink) {
52-
sink.asExpr() = any(ArrayParameter p).getAMatchingArgument()
52+
sink.asIndirectExpr() = any(ArrayParameter p).getAMatchingArgument()
5353
}
5454
}
5555

@@ -68,8 +68,8 @@ where
6868
or
6969
// the argument is a pointer and its value does not come from a literal of the correct
7070
arg.getType() instanceof PointerType and
71-
not exists(ArrayAggregateLiteral l |
72-
SmallArrayFlow::flow(DataFlow::exprNode(l), DataFlow::exprNode(arg)) and
71+
not exists(ArrayAggregateLiteral l, DataFlow::Node arg_node | arg_node.asIndirectExpr() = arg |
72+
SmallArrayFlow::flow(DataFlow::exprNode(l), arg_node) and
7373
countElements(l) >= p.getArraySize()
7474
)
7575
)

c/misra/test/rules/RULE-17-5/ArrayFunctionArgumentNumberOfElements.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:48,36-44)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:49,22-30)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:51,20-28)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:56,25-33)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:72,28-36)
6-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (ArrayFunctionArgumentNumberOfElements.ql:72,51-59)
71
| test.c:18:6:18:6 | 0 | The function argument does not have a sufficient number or elements declared in the $@. | test.c:1:13:1:14 | ar | parameter |
82
| test.c:19:6:19:7 | ar | The function argument does not have a sufficient number or elements declared in the $@. | test.c:1:13:1:14 | ar | parameter |
93
| test.c:21:6:21:9 | ar2p | The function argument does not have a sufficient number or elements declared in the $@. | test.c:1:13:1:14 | ar | parameter |

0 commit comments

Comments
 (0)