Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.1k
Shared/C++: Handle non-standard return values in MaD flow sources/sinks#19569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MathiasVP
merged 4 commits into
github:main
from
MathiasVP:fix-return-value-surces-in-madMay 23, 2025
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 5 additions & 1 deletion
6 cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 31 additions & 7 deletions
38 shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -54,6 +54,20 @@ signature module InputSig<LocationSig Location, DF::InputSig<Location> Lang> { | ||
| /** Gets the return kind corresponding to specification `"ReturnValue"`. */ | ||
| Lang::ReturnKind getStandardReturnValueKind(); | ||
| /** | ||
| * Gets the return kind corresponding to specification `"ReturnValue"` when | ||
| * supplied with the argument `arg`. | ||
| * | ||
| * Note that it is expected that the following equality holds: | ||
| * ``` | ||
| * getReturnValueKind("") = getStandardReturnValueKind() | ||
| * ``` | ||
| */ | ||
| default Lang::ReturnKind getReturnValueKind(string arg) { | ||
| arg = "" and | ||
| result = getStandardReturnValueKind() | ||
| } | ||
| /** Gets the textual representation of parameter position `pos` used in MaD. */ | ||
| string encodeParameterPosition(Lang::ParameterPosition pos); | ||
| @@ -2164,9 +2178,15 @@ module Make< | ||
| ) | ||
| ) | ||
| or | ||
| c = "ReturnValue" and | ||
| node.asNode() = | ||
| getAnOutNodeExt(mid.asCall(), TValueReturn(getStandardReturnValueKind())) | ||
| c.getName() = "ReturnValue" and | ||
| exists(ReturnKind rk | | ||
| not exists(c.getAnArgument()) and | ||
| rk = getStandardReturnValueKind() | ||
| or | ||
| rk = getReturnValueKind(c.getAnArgument()) | ||
| | | ||
| node.asNode() = getAnOutNodeExt(mid.asCall(), TValueReturn(rk)) | ||
| ) | ||
| or | ||
| SourceSinkInterpretationInput::interpretOutput(c, mid, node) | ||
| ) | ||
| @@ -2198,12 +2218,16 @@ module Make< | ||
| ) | ||
| ) | ||
| or | ||
| exists(ReturnNode ret, ValueReturnKind kind | | ||
| c = "ReturnValue" and | ||
| exists(ReturnNode ret, ReturnKind kind | | ||
jketema marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| c.getName() = "ReturnValue" and | ||
| ret = node.asNode() and | ||
| kind.getKind() = ret.getKind() and | ||
| kind.getKind() = getStandardReturnValueKind() and | ||
| kind = ret.getKind() and | ||
| mid.asCallable() = getNodeEnclosingCallable(ret) | ||
| | | ||
| not exists(c.getAnArgument()) and | ||
| kind = getStandardReturnValueKind() | ||
| or | ||
| kind = getReturnValueKind(c.getAnArgument()) | ||
| ) | ||
| or | ||
| SourceSinkInterpretationInput::interpretInput(c, mid, node) | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.