pcap_dump_flush
API 概述
pcap_dump_flush 是 libpcap 中的一个API。该规属于return value check 类型。该规则是使用 Advance 生成的。
规则描述
提示
pcap_dump_flush() returns 0 on success and PCAP_ERROR on failure.
信息
标签:return value check
参数下标:N/A
CWE类别:CWE-253
规则代码
import semmle.code.cpp.dataflow.DataFlow
class TestConfiguration extends DataFlow::Configuration {
TestConfiguration() { this = "TestConfiguration" }
override predicate isSource(DataFlow::Node source) {
exists(FunctionCall fc, MacroInvocation mi |
(fc.getTarget().hasQualifiedName("pcap_dump_flush") or (
mi.getMacroName() = "pcap_dump_flush"
and fc.getTarget().hasName(mi.getMacro().getBody())
)
)
and fc = source.asExpr()
)
}
override predicate isSink(DataFlow::Node sink) {
exists(| sink.asExpr().getEnclosingStmt() instanceof IfStmt
and (sink.asExpr().getParent() instanceof ComparisonOperation
or sink.asExpr().getParent() instanceof NotExpr
or sink.asExpr().getParent() instanceof IfStmt
)
)
}
}
from TestConfiguration cfg, FunctionCall fc, MacroInvocation mi
//function not checked
where (fc.getTarget().hasQualifiedName("pcap_dump_flush") or (
mi.getMacroName() = "pcap_dump_flush"
and fc.getTarget().hasName(mi.getMacro().getBody())
))
and (
(fc instanceof ExprInVoidContext)
or not exists(Expr source1, Expr sink1|cfg.hasFlow(DataFlow::exprNode(source1), DataFlow::exprNode(sink1)) and fc = source1)
)
select fc.getLocation()