Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe6c9f9

Browse files
committed
CPP: Stricter dataflow in getBufferSize.
1 parent beb21f9 commit fe6c9f9

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

cpp/ql/src/semmle/code/cpp/commons/Buffer.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ int getBufferSize(Expr bufferExpr, Element why) {
8080
// buffer is a fixed size dynamic allocation
8181
isFixedSizeAllocationExpr(bufferExpr, result) and
8282
why = bufferExpr
83-
) or exists(Expr def, Element why2 |
83+
) or forex(Expr def |
8484
// dataflow
85-
DataFlow::localFlowStep(DataFlow::exprNode(def), DataFlow::exprNode(bufferExpr)) and
86-
result = getBufferSize(def, why2) and
87-
(
88-
why = def or
89-
why = why2
85+
DataFlow::localFlowStep(DataFlow::exprNode(def), DataFlow::exprNode(bufferExpr)) |
86+
exists(Element why2 |
87+
result = getBufferSize(def, why2) and
88+
(
89+
why = def or
90+
why = why2
91+
)
9092
)
9193
) or exists(Type bufferType |
9294
// buffer is the address of a variable

0 commit comments

Comments
 (0)