File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
cpp/ql/src/semmle/code/cpp/models/implementations Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import semmle.code.cpp.Function
2+ import semmle.code.cpp.models.interfaces.ArrayFunction
3+ import semmle.code.cpp.models.interfaces.DataFlow
4+ import semmle.code.cpp.models.interfaces.Taint
5+
6+ /**
7+ * The standard function `memset` and its assorted variants
8+ */
9+ class MemsetFunction extends ArrayFunction , DataFlowFunction , TaintFunction {
10+ MemsetFunction ( ) {
11+ hasGlobalName ( "memset" ) or
12+ hasGlobalName ( "bzero" ) or
13+ hasGlobalName ( "__builtin_memset" ) or
14+ hasQualifiedName ( "std" , "memset" )
15+ }
16+
17+ override predicate hasArrayOutput ( int bufParam ) { bufParam = 0 }
18+
19+ override predicate hasDataFlow ( FunctionInput input , FunctionOutput output ) {
20+ input .isInParameter ( 0 ) and
21+ output .isOutReturnValue ( )
22+ }
23+
24+ override predicate hasArrayWithVariableSize ( int bufParam , int countParam ) {
25+ bufParam = 0 and
26+ ( if hasGlobalName ( "bzero" ) then countParam = 1 else countParam = 2 )
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments