Geoffrey White
885df8754e
Merge pull request #1165 from dave-bartolomeo/dave/CompareFP
...
C++: Fix FP in PointlessComparison due to preprocessor
2019-03-27 10:54:26 +00:00
Jonas Jensen
36ba56c690
C++: Tests for PointlessComparison shortcomings
2019-03-27 10:48:35 +01:00
Jonas Jensen
1ffeebcfea
C++: Range analysis: support casts from/to typedef
2019-03-27 10:48:35 +01:00
Jonas Jensen
1c71c74ce5
C++: Tests showing problems with casts of typedefs
2019-03-27 10:48:35 +01:00
Jonas Jensen
50559d5e63
C++: Accept test output change
...
The new output looks correct, although I'm not sure if it's correct for
the right reasons.
2019-03-27 10:48:34 +01:00
Geoffrey White
69f87d8eee
CPP: Fix ODASA-3654.
2019-03-26 12:54:44 +00:00
Geoffrey White
bd138238b0
CPP: Add a test of ODASA-3654.
2019-03-26 12:37:32 +00:00
Dave Bartolomeo
669ac2f4b4
C++: Fix FP in PointlessComparison due to preprocessor
...
Reported by an LGTM customer here: https://discuss.lgtm.com/t/2-false-positives-in-c-for-comparison-is-always-same/1943 .
Even though the comparison is pointless in the preprocessor configuration in effect during extraction, it is not pointless in other preprocessor configurations. Similar to ExprHasNoEffect, we'll now exclude results in functions that contain preprocessor-excluded code. I factored the similar code already used in ExprHasNoEffect in a non-recursive version into Preprocessor.qll, leaving the recursive version in ExprHasNoEffect.ql. I believe the recursive version is too aggressive for PointerlessComparison, which does no interprocedural analysis.
2019-03-25 16:19:18 -07:00
Ziemowit Laski
29af56d21b
[CPP-340] Refine the test query for mismatching args/params by applying
...
C promotion rules. The following issues are now flagged:
(1) passing a larger type than the receiver can accept
(e.g., long long -> int)
(2) passing a type of different signedness than the
parameter specified.
2019-03-24 19:42:05 -07:00
Ziemowit Laski
5a092d0fed
[CPP-340] Create three QL queries: (1) mismatched argument types,
...
(2) too few arguments and (3) too many arguments.
Create new 'UnderspecifiedFunction' folders for both queries and tests.
2019-03-20 19:42:51 -07:00
Ziemowit Laski
2def0ee9c1
[CPP-340] Re-work QL query; treat undeclared C functions the same way as
...
()-declared functions.
2019-03-19 16:01:35 -07:00
Ziemowit Laski
0c350dc504
[CPP-340] Create QL query for function call argument count mismatches.
...
Update QHELP file, test and test results.
2019-03-19 16:00:02 -07:00
zlaski-semmle
241994d1f8
Merge pull request #1107 from zlaski-semmle/cpp355
...
Updated query to look for Microsoft-specific '_alloca' and '_malloca'
Merge to Semmle/ql:master.
2019-03-19 13:40:27 -07:00
Ziemowit Laski
09e729ff59
Turns out that '__builtin_alloca' takes 'unsigned long', not 'unsigned long long'; rename some parameters to align with C11 standard.
2019-03-19 13:27:14 -07:00
Ziemowit Laski
11ed4f3312
Change __builtin_alloca declaration to use an unsigned long long parameter.
2019-03-19 13:12:29 -07:00
Ziemowit Laski
ff3430d8d0
Use '// GOOD' and '// BAD' annotations for query diagnostics.
2019-03-19 12:29:38 -07:00
Max Schaefer
6fbf487524
Merge remote-tracking branch 'upstream/rc/1.20' into mergeback-2019-03-19
2019-03-19 14:09:03 +00:00
Jonas Jensen
111a462d16
C++: Recover some of the good results we lost
...
My recent changes to suppress FPs in `ReturnStackAllocatedMemory.ql`
caused us to lose all results where there was a `Conversion` at the
initial address escape. We cannot handle conversions in general, but
this commit restores the good results for the trivial types of
conversion that we can handle.
2019-03-19 11:09:58 +01:00
Jonas Jensen
d864df5b7f
C++: Tests for new false negatives
2019-03-19 10:30:14 +01:00
Ziemowit Laski
566fdc3f70
Change names of parameters to memcpy(), as per Geoff.
2019-03-18 11:15:43 -07:00
Jonas Jensen
6b1cd17009
C++: Fix FPs due to data flow Conversion handling
...
Since we cannot track data flow from a fully-converted expression but
only the unconverted expression, we should check whether the address
initially escapes into the unconverted expression, not the
fully-converted one.
This fixes most of the false positives observed on lgtm.com.
2019-03-16 20:50:27 +01:00
Jonas Jensen
1a7351ef6e
C++: Add tests for three FPs observed on lgtm.com
2019-03-16 20:50:27 +01:00
Ziemowit Laski
2d5bdc85b0
Add 'restrict' support to the C++ test cases.
2019-03-14 12:12:45 -07:00
Ziemowit Laski
586aa0ae41
Updated query to look for Microsoft-specific '_alloca' and '_malloca' entry points. Added sundry positive and negative test cases.
2019-03-13 18:43:24 -07:00
Geoffrey White
9f9712047c
CPP: Add a few more tests of '%c'.
2019-03-06 10:23:45 +00:00
Geoffrey White
66013272da
Merge pull request #894 from jbj/ir-RedundantNullCheckSimple
...
C++: IR query for redundant null check
2019-03-01 15:34:18 +00:00
Jonas Jensen
b9236d216f
C++: Improve ReturnStackAllocatedMemory alert msg
2019-02-21 11:20:25 +01:00
Jonas Jensen
dcf910f20c
C++: Use EscapesTree to find pointers to stack
...
This simplifies the query and is a strict improvement on the tests. I
also found it to be an overall improvement on real projects.
2019-02-21 11:20:25 +01:00
Jonas Jensen
9f2fdbbc1d
C++: More tests for RedundantNullCheckSimple
2019-02-21 10:13:25 +01:00
Jonas Jensen
9ac8d60636
C++: IR query for redundant null check
...
This new query is not written because it's the most interesting query we
could write but because it's an IR-based query whose results are easy to
verify.
2019-02-21 10:13:25 +01:00
Geoffrey White
6a17ebbd1b
CPP: Add test cases and renumber.
2019-02-20 10:09:57 +00:00
Geoffrey White
4e77f586da
CPP: Fix file names.
2019-02-20 10:08:27 +00:00
Geoffrey White
07adf6f201
CPP: Handle array accesses.
2019-01-30 18:36:32 +00:00
Geoffrey White
4685f193f5
CPP: Widen varMaybeStackAllocated.
2019-01-30 18:36:32 +00:00
Geoffrey White
25e11512db
CPP: Add a test of ReturnStackAllocatedMemory.
2019-01-30 18:36:31 +00:00
Jonas Jensen
d776d9f903
Merge pull request #821 from geoffw0/query-tags-case
...
CPP: Improve ArrayArgSizeMismatch.ql
2019-01-29 03:52:52 -08:00
semmle-qlci
bf64fee4bd
Merge pull request #790 from rdmarsh2/rdmarsh/cpp/futile-params
...
Approved by semmledocs-ac
2019-01-28 22:11:44 +00:00
Robert Marsh
44d8e6b6e2
C++: respond to PR comments
2019-01-24 10:50:56 -08:00
Geoffrey White
02c69a744f
CPP: Fix false positive.
2019-01-24 15:15:02 +00:00
Geoffrey White
e1d31bf117
CPP: Add a test of ArrayArgSizeMismatch.ql.
2019-01-24 11:20:58 +00:00
Jonas Jensen
61e23bed88
Merge branch 'master' into strcpy-fixups
2019-01-24 10:51:51 +01:00
Robert Marsh
fa02042fda
C++: add more tests and rename test functions
2019-01-23 11:42:44 -08:00
Dave Bartolomeo
bfb8125474
Merge pull request #754 from jbj/copy-assignment-no-effect
...
C++: Exclude assignment operator in ExprHasNoEffect
2019-01-23 00:46:17 -08:00
Jonas Jensen
189d82b79a
C++: Change exclusion to not be only operator=
2019-01-18 11:19:38 +01:00
Robert Marsh
64ed9305d3
C++: new query for futile arguments to C functions
2019-01-17 10:45:10 -08:00
Jonas Jensen
f147b63bb8
Merge pull request #654 from geoffw0/lossyresultcast
...
CPP: Work on Lossy function result cast query
2019-01-17 17:07:29 +01:00
Jonas Jensen
9751a91087
C++: Accept changes to alert message in test
2019-01-14 21:43:57 +01:00
Jonas Jensen
6385dd38cf
C++: Exclude operator= in ExprHasNoEffect
2019-01-11 13:30:08 +01:00
Jonas Jensen
95e457cb49
C++: Add test with FP in ExprHasNoEffect
2019-01-11 13:18:44 +01:00
Geoffrey White
f2e68da322
CPP: Use dataflow to find wrapped rounding functions.
2019-01-10 14:44:11 +00:00