File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
cpp/ql/src/experimental/Security/CVE Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ import cpp
2+
3+ class CopyFromUserFunctionCall extends FunctionCall {
4+ CopyFromUserFunctionCall ( ) {
5+ this .getTarget ( ) .getName ( ) = "copy_from_user"
6+ and not this .getArgument ( 1 ) instanceof AddressOfExpr
7+ }
8+
9+ predicate hasSameArguments ( CopyFromUserFunctionCall another ) {
10+ this .getArgument ( 0 ) .toString ( ) = another .getArgument ( 0 ) .toString ( )
11+ and this .getArgument ( 1 ) .toString ( ) = another .getArgument ( 1 ) .toString ( )
12+ }
13+
14+ }
15+
16+ from CopyFromUserFunctionCall p1 , CopyFromUserFunctionCall p2
17+ where
18+ not p1 = p2
19+ and p1 .hasSameArguments ( p2 )
20+ and exists ( IfStmt ifStmt |
21+ p1 .getBasicBlock ( ) .getAFalseSuccessor * ( ) = ifStmt .getBasicBlock ( )
22+ and ifStmt .getBasicBlock ( ) .getAFalseSuccessor * ( ) = p2 .getBasicBlock ( )
23+ )
24+ and not exists ( AssignPointerAddExpr assignPtrAdd |
25+ p1 .getArgument ( 1 ) .toString ( ) = assignPtrAdd .getLValue ( ) .toString ( )
26+ and p1 .getBasicBlock ( ) .getAFalseSuccessor * ( ) = assignPtrAdd .getBasicBlock ( )
27+ )
28+ select
29+ "first fetch" , p1 , "double fetch" , p2
30+
31+
32+
33+
34+
You can’t perform that action at this time.
0 commit comments