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 1515 */
1616
1717import cpp
18+ import semmle.code.cpp.valuenumbering.GlobalValueNumbering
1819
1920class CopyFromUserFunctionCall extends FunctionCall {
2021 CopyFromUserFunctionCall ( ) {
2122 this .getTarget ( ) .getName ( ) = "copy_from_user"
2223 and not this .getArgument ( 1 ) instanceof AddressOfExpr
2324 }
2425
25- predicate hasSameArguments ( CopyFromUserFunctionCall another ) {
26+ /* predicate hasSameArguments(CopyFromUserFunctionCall another){
2627 this.getArgument(0).toString() = another.getArgument(0).toString()
2728 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 ) )
2834 }
2935
3036}
@@ -38,11 +44,12 @@ where
3844 and ifStmt .getBasicBlock ( ) .getAFalseSuccessor * ( ) = p2 .getBasicBlock ( )
3945 )
4046 and not exists ( AssignPointerAddExpr assignPtrAdd |
41- p1 .getArgument ( 1 ) . toString ( ) = assignPtrAdd .getLValue ( ) . toString ( )
47+ globalValueNumber ( p1 .getArgument ( 1 ) ) = globalValueNumber ( assignPtrAdd .getLValue ( ) )
4248 and p1 .getBasicBlock ( ) .getAFalseSuccessor * ( ) = assignPtrAdd .getBasicBlock ( )
4349 )
44- select
45- "first fetch" , p1 , "double fetch" , p2
50+
51+ select p2 , "Double fetch vulnerability. First fetch was $@." , p1 , p1 .toString ( )
52+
4653
4754
4855
You can’t perform that action at this time.
0 commit comments