Merge pull request #5607 from MathiasVP/smart-pointer-ast-read-store-steps

C++: read and store steps for smart pointers in AST dataflow
This commit is contained in:
Jonas Jensen
2021-04-09 16:11:48 +02:00
committed by GitHub
3 changed files with 91 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import semmle.code.cpp.models.interfaces.Taint
import semmle.code.cpp.models.interfaces.DataFlow
import semmle.code.cpp.models.interfaces.PointerWrapper
/**
@@ -14,6 +15,23 @@ private class UniqueOrSharedPtr extends Class, PointerWrapper {
}
}
/** Any function that unwraps a pointer wrapper class to reveal the underlying pointer. */
private class PointerWrapperDataFlow extends DataFlowFunction {
PointerWrapperDataFlow() {
this = any(PointerWrapper wrapper).getAnUnwrapperFunction() and
not this.getUnspecifiedType() instanceof ReferenceType
}
override predicate hasDataFlow(FunctionInput input, FunctionOutput output) {
input.isQualifierAddress() and output.isReturnValue()
or
input.isQualifierObject() and output.isReturnValueDeref()
or
input.isReturnValueDeref() and
output.isQualifierObject()
}
}
/**
* The `std::make_shared` and `std::make_unique` template functions.
*/