File tree Expand file tree Collapse file tree
cpp/ql/src/semmle/code/cpp/models/implementations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55import semmle.code.cpp.models.interfaces.Taint
66
7+ /**
8+ * An instantiation of `std::pair<T1, T2>`.
9+ */
10+ class StdPairClass extends ClassTemplateInstantiation {
11+ StdPairClass ( ) { getTemplate ( ) .hasQualifiedName ( "std" , "pair" ) }
12+ }
13+
14+ /**
15+ * Any of the single-parameter constructors of `std::pair` that takes a reference to an
16+ * instantiation of `std::pair`. These constructors allow conversion between pair types when the
17+ * underlying element types are convertible.
18+ */
19+ class StdPairCopyishConstructor extends Constructor , TaintFunction {
20+ StdPairCopyishConstructor ( ) {
21+ this .getDeclaringType ( ) instanceof StdPairClass and
22+ this .getNumberOfParameters ( ) = 1 and
23+ this .getParameter ( 0 ) .getUnspecifiedType ( ) .( ReferenceType ) .getBaseType ( ) .getUnspecifiedType ( )
24+ instanceof StdPairClass
25+ }
26+
27+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
28+ // taint flow from the source object to the constructed object
29+ input .isParameterDeref ( 0 ) and
30+ (
31+ output .isReturnValue ( )
32+ or
33+ output .isQualifierObject ( )
34+ )
35+ }
36+ }
37+
738/**
839 * Additional model for `std::pair` constructors.
940 */
You can’t perform that action at this time.
0 commit comments