Skip to content

C++: Refine examples and tests for cpp/memory-unsafe-function-scan (experimental) query #4805

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 2 commits into from
Dec 11, 2020

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Dec 9, 2020

I ran this query today and found a false positive on an sscanf call. Because the source is a buffer, its perfectly possible to know or check the length beforehand and allocate sufficient space in the destination buffer, unlike for scanf or fscanf where you don't tend to know what's coming.

I was tempted to exclude sscanf results from the query, but this seems to be the majority of results in the wild and some of them look like good results to me. Maybe we can do something more clever. But for now I've just documented the problem through a test.

Also fixed a mistake in one of the examples.

@geoffw0 geoffw0 added the C++ label Dec 9, 2020
@geoffw0 geoffw0 requested a review from a team as a code owner December 9, 2020 17:30
@rdmarsh2 rdmarsh2 merged commit af180d4 into github:main Dec 11, 2020
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