Skip to content

Commit 42fd3fc

Browse files
authored
C++: Make more things 'private' and add QLDoc to public things. (#40)
1 parent da10e6c commit 42fd3fc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

cpp/ql/lib/semmle/code/cpp/security/flowafterfree/FlowAfterFree.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ predicate strictlyDominates(IRBlock b1, int i1, IRBlock b2, int i2) {
2828
b1.strictlyDominates(b2)
2929
}
3030

31+
/**
32+
* The signature for a module that is used to specify the inputs to the `FlowFromFree` module.
33+
*/
3134
signature module FlowFromFreeParamSig {
3235
/**
33-
* Signature for a predicate that holds if `n.asExpr() = e` and `n` is a sink in
34-
* the `FlowFromFreeConfig` module.
36+
* Holds if `n.asExpr() = e` and `n` is a sink in the `FlowFromFreeConfig`
37+
* module.
3538
*/
3639
predicate isSink(DataFlow::Node n, Expr e);
3740

@@ -60,7 +63,7 @@ signature module FlowFromFreeParamSig {
6063
* 2. The sink post-dominates the source.
6164
*/
6265
module FlowFromFree<FlowFromFreeParamSig P> {
63-
module FlowFromFreeConfig implements DataFlow::StateConfigSig {
66+
private module FlowFromFreeConfig implements DataFlow::StateConfigSig {
6467
class FlowState instanceof Expr {
6568
FlowState() { isFree(_, _, this, _) }
6669

cpp/ql/lib/semmle/code/cpp/security/flowafterfree/UseAfterFree.qll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ predicate isUse0(Expr e) {
4141
)
4242
}
4343

44-
module ParameterSinks {
44+
private module ParameterSinks {
4545
import semmle.code.cpp.ir.ValueNumbering
4646

47-
predicate flowsToUse(DataFlow::Node n) {
47+
private predicate flowsToUse(DataFlow::Node n) {
4848
isUse0(n.asExpr())
4949
or
5050
exists(DataFlow::Node succ |
@@ -131,9 +131,15 @@ module ParameterSinks {
131131
}
132132
}
133133

134-
module IsUse {
134+
private module IsUse {
135135
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
136136

137+
/**
138+
* Holds if `n` represents the expression `e`, and `e` is a pointer that is
139+
* guarenteed to be dereferenced (either because it's an operand of a
140+
* dereference operation, or because it's an argument to a function that
141+
* always dereferences the parameter).
142+
*/
137143
predicate isUse(DataFlow::Node n, Expr e) {
138144
isUse0(e) and n.asExpr() = e
139145
or

0 commit comments

Comments
 (0)