-
Notifications
You must be signed in to change notification settings - Fork 82
EXP39-C: False positives related to compatible types, harmless casts #1200
Copy link
Copy link
Open
Labels
Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to addressA false positive or false negative report which is expected to take 1-5 days effort to addressImpact-MediumStandard-CERT-Cfalse positive/false negativeAn issue related to observed false positives or false negatives.An issue related to observed false positives or false negatives.false-positiveAn issue representing a false positive report.An issue representing a false positive report.
Description
Activity
Metadata
Metadata
Assignees
Labels
Difficulty-MediumA false positive or false negative report which is expected to take 1-5 days effort to addressA false positive or false negative report which is expected to take 1-5 days effort to addressImpact-MediumStandard-CERT-Cfalse positive/false negativeAn issue related to observed false positives or false negatives.An issue related to observed false positives or false negatives.false-positiveAn issue representing a false positive report.An issue representing a false positive report.
Affected rules
EXP39-CDescription
First off, our implementation uses a
compatibleTypespredicate that is incomplete and doesn't handle typedefs, and should be replaced with our common/types/Compatible.qll library. This results in thousands of false positives in certain codebases, usually due to casting to a project-specific typedef of a byte likeGLBYTE*.Secondly, while we use dataflow to trace realloc's that flow to a deref without a memset, we don't use dataflow to handle the more typical case of
A*cast toB*followed by a deref. Instead, we have a type representing casted expressions that's both a sink and a source. (We check compatibility of the pointers in the cast in the select statement). This isn't strictly UB unless the pointer is dereferenced, and I do see examples of this in real code. As a related example, casts tovoid**are often flagged whilevoid*is excluded. This isn't a rare exceptional use ofvoid, it's really just a harmless cast.Example