Skip to content

Commit 1d30fd5

Browse files
committed
Convert DCL30-C to the new dataflow library
Observe that this change moves the alert location from the last assignment of an output parameter to the paramter itself, which seems a non-critical change.
1 parent 7c7d6f6 commit 1d30fd5

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

c/cert/src/rules/DCL30-C/AppropriateStorageDurationsFunctionReturn.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import cpp
2020
import codingstandards.c.cert
2121
import codingstandards.c.Objects
22-
import semmle.code.cpp.dataflow.DataFlow
22+
import semmle.code.cpp.dataflow.new.DataFlow
2323

2424
class Source extends Expr {
2525
ObjectIdentity rootObject;
@@ -34,7 +34,7 @@ class Sink extends DataFlow::Node {
3434
Sink() {
3535
//output parameter
3636
exists(Parameter f |
37-
f.getAnAccess() = this.(DataFlow::PostUpdateNode).getPreUpdateNode().asExpr() and
37+
this.isFinalValueOfParameter(f) and
3838
f.getUnderlyingType() instanceof PointerType
3939
)
4040
or
Lines changed: 1 addition & 6 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 (AppropriateStorageDurationsFunctionReturn.ql:33,20-28)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateStorageDurationsFunctionReturn.ql:37,31-39)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateStorageDurationsFunctionReturn.ql:50,6-14)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateStorageDurationsFunctionReturn.ql:50,26-34)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateStorageDurationsFunctionReturn.ql:56,3-11)
61
| test.c:3:10:3:10 | a | $@ with automatic storage may be accessible outside of its lifetime. | test.c:3:10:3:10 | a | a |
7-
| test.c:15:4:15:8 | param [inner post update] | $@ with automatic storage may be accessible outside of its lifetime. | test.c:15:12:15:13 | a2 | a2 |
2+
| test.c:12:16:12:20 | *param | $@ with automatic storage may be accessible outside of its lifetime. | test.c:15:12:15:13 | a2 | a2 |

0 commit comments

Comments
 (0)