File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
cpp/ql/src/experimental/Security/CWE/CWE-362 Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
17
17
import cpp
18
+ import semmle.code.cpp.valuenumbering.GlobalValueNumbering
18
19
19
20
class CopyFromUserFunctionCall extends FunctionCall {
20
21
CopyFromUserFunctionCall ( ) {
21
22
this .getTarget ( ) .getName ( ) = "copy_from_user"
22
23
and not this .getArgument ( 1 ) instanceof AddressOfExpr
23
24
}
24
25
25
- predicate hasSameArguments ( CopyFromUserFunctionCall another ) {
26
+ /* predicate hasSameArguments(CopyFromUserFunctionCall another){
26
27
this.getArgument(0).toString() = another.getArgument(0).toString()
27
28
and this.getArgument(1).toString() = another.getArgument(1).toString()
29
+ }*/
30
+
31
+ predicate hasSameArguments ( CopyFromUserFunctionCall another ) {
32
+ globalValueNumber ( this .getArgument ( 0 ) ) = globalValueNumber ( another .getArgument ( 0 ) )
33
+ and globalValueNumber ( this .getArgument ( 1 ) ) = globalValueNumber ( another .getArgument ( 1 ) )
28
34
}
29
35
30
36
}
@@ -38,11 +44,12 @@ where
38
44
and ifStmt .getBasicBlock ( ) .getAFalseSuccessor * ( ) = p2 .getBasicBlock ( )
39
45
)
40
46
and not exists ( AssignPointerAddExpr assignPtrAdd |
41
- p1 .getArgument ( 1 ) . toString ( ) = assignPtrAdd .getLValue ( ) . toString ( )
47
+ globalValueNumber ( p1 .getArgument ( 1 ) ) = globalValueNumber ( assignPtrAdd .getLValue ( ) )
42
48
and p1 .getBasicBlock ( ) .getAFalseSuccessor * ( ) = assignPtrAdd .getBasicBlock ( )
43
49
)
44
- select
45
- "first fetch" , p1 , "double fetch" , p2
50
+
51
+ select p2 , "Double fetch vulnerability. First fetch was $@." , p1 , p1 .toString ( )
52
+
46
53
47
54
48
55
You can’t perform that action at this time.
0 commit comments