Skip to content

C++: Add StrlenLiteralRangeExpr #12650

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
merged 1 commit into from
Mar 24, 2023

Conversation

gsingh93
Copy link
Contributor

While determining the range of the return value of strlen is difficult in the general case, we can precisely and efficiently determine the range when the argument is a literal string. This extra precision can help reduce false positives in some queries.

@gsingh93 gsingh93 requested a review from a team as a code owner March 24, 2023 00:25
@github-actions github-actions bot added the C++ label Mar 24, 2023
MathiasVP
MathiasVP previously approved these changes Mar 24, 2023
Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. This LGTM :)

@MathiasVP MathiasVP dismissed their stale review March 24, 2023 11:03

Oops. I forgot to say that this extension should also be imported in cpp/ql/lib/experimental/semmle/code/cpp/rangeanalysis/ExtendedRangeAnalysis.qll

@gsingh93 gsingh93 force-pushed the strlen-literal-range-expr branch from bf46946 to 67eb129 Compare March 24, 2023 15:50
@gsingh93 gsingh93 force-pushed the strlen-literal-range-expr branch from 67eb129 to b87f12d Compare March 24, 2023 15:51
@gsingh93
Copy link
Contributor Author

Fixed.

Copy link
Contributor

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +4 to +7
/**
* Provides range analysis information for calls to `strlen` on literal strings.
* For example, the range of `strlen("literal")` will be 7.
*/

Check warning

Code scanning / CodeQL

Class QLDoc style.

The QLDoc for a class should start with 'A', 'An', or 'The'.
@MathiasVP MathiasVP merged commit 86cc59e into github:main Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants