Skip to content

CPP: Add query for CWE-754: Improper Check for Unusual or Exceptional Conditions when using functions scanf #8246

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 22 commits into from
Mar 11, 2022

Conversation

ihsinme
Copy link
Contributor

@ihsinme ihsinme commented Feb 25, 2022

the query looks for situations of working with scanf functions in situations where the developer has not left the possibility of controlling the correctness of work. There is no check of the returned value, the filled variable is not initialized and its value is not evaluated after the function has run. this leads to a situation where, continuing to work with a filled variable, the developer runs the risk of working with a randomly filled value at the declaration stage.

CVE-2019-15900

I'm working on a real fix for this issue.

Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

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

Hi @ihsinme. Thanks for your contribution. Some comments below.

@ihsinme
Copy link
Contributor Author

ihsinme commented Mar 1, 2022

thanks for the comments.
I will try to fix everything as soon as possible.

Copy link
Contributor

@jketema jketema 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 the updates, especially making the tests cover more cases.

ihsinme and others added 2 commits March 8, 2022 07:42
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
@ihsinme
Copy link
Contributor Author

ihsinme commented Mar 8, 2022

I want to thank you for your corrections.
especially the English text.

Copy link
Contributor

@jketema jketema 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 the contribution and addressing my comments.

Not for this PR, but you might want to have a look at the data flow library https://codeql.github.com/docs/codeql-language-guides/analyzing-data-flow-in-cpp/. I think that a rewrite based on that library might help to improve the quality of the analysis of what happens after a scanf call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants