Skip to content

Commit 4a0b2b6

Browse files
committed
Java: Explicitly tie ReturnNode to TargetApi before calling returnNodeAsOutput.
1 parent 44949b6 commit 4a0b2b6

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

java/ql/src/utils/model-generator/CaptureSourceModels.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ string captureSource(TargetAPI api) {
4444
config.hasFlow(source, sink) and
4545
sourceNode(source, kind) and
4646
api = source.getEnclosingCallable() and
47-
result = asSourceModel(api, returnNodeAsOutput(api, sink), kind)
47+
api = sink.getEnclosingCallable() and
48+
result = asSourceModel(api, returnNodeAsOutput(sink), kind)
4849
)
4950
}
5051

java/ql/src/utils/model-generator/CaptureSummaryModels.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ string captureThroughFlow(TargetAPI api) {
153153
config.hasFlow(p, returnNodeExt) and
154154
returnNodeExt.getEnclosingCallable() = api and
155155
input = parameterNodeAsInput(p) and
156-
output = returnNodeAsOutput(api, returnNodeExt) and
156+
output = returnNodeAsOutput(returnNodeExt) and
157157
input != output and
158158
result = asTaintModel(api, input, output)
159159
)

java/ql/src/utils/model-generator/ModelGeneratorUtils.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,12 @@ string parameterNodeAsInput(DataFlow::ParameterNode p) {
165165
result = "Argument[-1]" and p instanceof DataFlow::InstanceParameterNode
166166
}
167167

168-
bindingset[api]
169-
string returnNodeAsOutput(TargetAPI api, ReturnNodeExt node) {
168+
string returnNodeAsOutput(ReturnNodeExt node) {
170169
if node.getKind() instanceof ValueReturnKind
171170
then result = "ReturnValue"
172171
else
173172
exists(int pos | pos = node.getKind().(ParamUpdateReturnKind).getPosition() |
174-
result = parameterAccess(api.getParameter(pos))
173+
result = parameterAccess(node.getEnclosingCallable().getParameter(pos))
175174
or
176175
result = "Argument[-1]" and pos = -1
177176
)

0 commit comments

Comments
 (0)