-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fixing BasicIntTypes to allow C Standard Integers and 'bool' #18980
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
Conversation
The purpose of this check is to ensure that all integral types used by the code point to some fixed size type (e.g. an unsigned 8-bit integer). However; the previous implementation only allowed JPL style typedefs (i.e. U8) and ignored C standard integer types (i.e. uint8_t). This causes the query to false-positive when a typedef resolves to a C standard int type. 'bool' has also be allowed as part of the exclusions list as it represents distinct values 'true' and 'false' in C++ code.
There was a problem hiding this 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.
Reduced the category to minorAnalysis. Handled bools via a instanceof with BoolType. Formatted the query correctly.
@jketema thanks for the expedient review. I believe I have addressed the issues. |
Thanks for the updates. Looks like --- expected
+++ actual
@@ -1,3 +1,1 @@
| test.c:6:26:6:26 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. |
-| test.c:7:20:7:20 | x | x uses the basic integral type unsigned char rather than a typedef with size and signedness. |
-| test.c:10:16:10:20 | test7 | test7 uses the basic integral type unsigned char rather than a typedef with size and signedness. | So just remove the last two lines from the file. |
Should be fixed now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks again for your contribution!
@jketema thanks for helping me through the process! This was a very positive open source experience. |
The purpose of this check is to ensure that all integral types used by the code point to some fixed size type (e.g. an unsigned 8-bit integer). However, the previous implementation only allowed JPL style typedefs (i.e. U8) and ignored C standard integer types (i.e. uint8_t). This causes the query to false-positive when a typedef resolves to a C standard int type instead of the JPL type even though the spirit of the check has been met.
'bool' has also be allowed as part of the exclusions list as it represents distinct values 'true' and 'false' in C++ code.
Since this significantly reduces the false-positives on my project, I've labeled it "majorAnalysis" per: https://github.com/github/codeql/blob/main/docs/change-notes.md#query-pack-change-categories