-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from khanhnt2/step-10
step 10
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
/** | ||
* @kind path-problem | ||
*/ | ||
|
||
import cpp | ||
import semmle.code.cpp.dataflow.TaintTracking | ||
import DataFlow::PathGraph | ||
|
||
class NetworkByteSwap extends Expr { | ||
NetworkByteSwap () { | ||
exists(MacroInvocation invocation | ||
| invocation.getMacro().getName().regexpMatch("ntoh.*") | ||
| this = invocation.getExpr() | ||
) | ||
} | ||
} | ||
|
||
class Config extends TaintTracking::Configuration { | ||
Config() { this = "NetworkToMemFuncLength" } | ||
|
||
override predicate isSource(DataFlow::Node source) { | ||
source.asExpr() instanceof NetworkByteSwap | ||
} | ||
override predicate isSink(DataFlow::Node sink) { | ||
exists(FunctionCall call | ||
| sink.asExpr() = call.getArgument(2) | ||
| call.getTarget().getName() = "memcpy" | ||
) | ||
} | ||
} | ||
|
||
from Config cfg, DataFlow::PathNode source, DataFlow::PathNode sink | ||
where cfg.hasFlowPath(source, sink) | ||
select sink, source, sink, "Network byte swap flows to memcpy" |
2f2d520
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 query changed between
221af12
and2f2d520
after push torefs/heads/master
:10_taint_tracking.ql
Results for
10_taint_tracking.ql
: correct (9 results)