mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
C++: Address review comments.
This commit is contained in:
@@ -26,8 +26,7 @@ class StdStringCStr extends TaintFunction {
|
|||||||
class StdStringPlus extends TaintFunction {
|
class StdStringPlus extends TaintFunction {
|
||||||
StdStringPlus() {
|
StdStringPlus() {
|
||||||
this.hasQualifiedName("std", "operator+") and
|
this.hasQualifiedName("std", "operator+") and
|
||||||
this.getParameter(0).getType().getUnspecifiedType().(ReferenceType).getBaseType() =
|
this.getUnspecifiedType() = any(StdBasicString s).getAnInstantiation()
|
||||||
any(StdBasicString s).getAnInstantiation()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||||
@@ -49,9 +48,17 @@ class StdStringAppend extends TaintFunction {
|
|||||||
this.hasQualifiedName("std", "basic_string", "append")
|
this.hasQualifiedName("std", "basic_string", "append")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the index of a parameter to this function that is a string.
|
||||||
|
*/
|
||||||
|
int getAStringParameter() {
|
||||||
|
getParameter(result).getType() instanceof PointerType or
|
||||||
|
getParameter(result).getType() instanceof ReferenceType
|
||||||
|
}
|
||||||
|
|
||||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||||
// flow from parameter to string itself (qualifier) and return value
|
// flow from parameter to string itself (qualifier) and return value
|
||||||
input.isParameterDeref(0) and
|
input.isParameterDeref(getAStringParameter()) and
|
||||||
(
|
(
|
||||||
output.isQualifierObject() or
|
output.isQualifierObject() or
|
||||||
output.isReturnValueDeref()
|
output.isReturnValueDeref()
|
||||||
|
|||||||
Reference in New Issue
Block a user