C++: More effective barriers in the bounded
predicate for CWE-190
#6159
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.
Note: This PR is based on top of #6154. Please start the review at 142b78f. Once #6154 has been merged I'll rebase those commits away.<-- That PR is now merged, and has been rebased out of this PR.This PR makes
%
a barrier regardless of whether or not we can bound the right-hand side of the operator using range analysis.The barrier (with that restriction) was introduced in #5887. At that point, we didn't have a lot of results on the query since it only recognized calls to
rand()
as random sources.Now that we have more sources of randomness (i.e., since #6154) we have a lot more results, and it looks like the
%
barrier doesn't rule out as many results as we want it to. For examples of this, see the first two bullet points I wrote here: https://github.com/github/codeql-c-team/issues/553#issuecomment-867670535.Here's a difference run on our usual LGTM projects: https://lgtm.com/query/2650148462537684414/. All of the removed results look like false positives to me. It also removes some false positives on the
cpp/tainted-arithmetic
query, but it's difficult to create an LGTM difference query sincecpp/tainted-arithmetic
is still using theTaintTrackingConfiguration
configuration.This change has no effect on SAMATE.