Skip to content

Commit a2c904d

Browse files
committed
C++: Clarify the meanings of predicates.
1 parent eeb84d4 commit a2c904d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cpp/ql/src/Security/CWE/CWE-367/TOCTOUFilesystemRace.ql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import cpp
1616
import semmle.code.cpp.controlflow.Guards
1717

1818
/**
19-
* An operation on a filename.
19+
* An operation on a filename that is likely to modify the corresponding file
20+
* and may return an indication of success.
2021
*
2122
* Note: we're not interested in operations on file descriptors, as they
2223
* are better behaved.
@@ -48,7 +49,8 @@ FunctionCall filenameOperation(Expr path) {
4849
}
4950

5051
/**
51-
* A use of `access` (or similar) on a filename.
52+
* An operation on a filename that returns information in the return value but
53+
* does not modify the corresponding file. For example, `access`.
5254
*/
5355
FunctionCall accessCheck(Expr path) {
5456
exists(string name | name = result.getTarget().getName() |
@@ -62,7 +64,9 @@ FunctionCall accessCheck(Expr path) {
6264
}
6365

6466
/**
65-
* A use of `stat` (or similar) on a filename.
67+
* An operation on a filename that returns information via a pointer argument
68+
* and any return value, but does not modify the corresponding file. For
69+
* example, `stat`.
6670
*/
6771
FunctionCall stat(Expr path, Expr buf) {
6872
exists(string name | name = result.getTarget().getName() |
@@ -77,7 +81,7 @@ FunctionCall stat(Expr path, Expr buf) {
7781
}
7882

7983
/**
80-
* Holds if `use` points to `source`, either by being the same or by
84+
* Holds if `use` refers to `source`, either by being the same or by
8185
* one step of variable indirection.
8286
*/
8387
predicate referenceTo(Expr source, Expr use) {

0 commit comments

Comments
 (0)