Skip to content

Commit

Permalink
Merge pull request #18 from khanhnt2/step-10
Browse files Browse the repository at this point in the history
step 10
  • Loading branch information
khanhnt2 authored Apr 15, 2020
2 parents 221af12 + 5a3b11e commit 2f2d520
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions 10_taint_tracking.ql
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"

1 comment on commit 2f2d520

@github-actions
Copy link

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 and 2f2d520 after push to refs/heads/master:

  • 10_taint_tracking.ql

Results for 10_taint_tracking.ql: correct (9 results)

Please sign in to comment.