Commit Graph

484 Commits

Author SHA1 Message Date
Daniel Marjamäki e9b4ea44a2 Refactoring: Disable inconclusive checks. They can still be activated for debugging/testing purposes 2010-04-10 14:05:33 +02:00
Daniel Marjamäki b4e9185177 Fixed #1134 (improve check: pointer access out of bounds not detected (allocated with malloc)) 2010-04-10 07:57:29 +02:00
Daniel Marjamäki 9a4707c025 Fixed #1576 ('Index out of bounds' false positive) 2010-04-08 19:57:38 +02:00
Martin Ettl 2e11805c1a added TODO testcase for checking fwrite() and fread() check for buffer overrun 2010-04-06 20:56:01 +02:00
Reijo Tomperi c28b365ea0 astyle fix 2010-04-06 16:56:06 +03:00
Martin Ettl c4d1d47f6b fixed ticket 997, now fread and fwrite checked for bufferoverrun 2010-04-06 13:55:03 +02:00
Reijo Tomperi 928163b0cf Fix line number in previously committed unit test 2010-04-05 23:37:30 +03:00
Daniel Marjamäki 0cffe547f9 Unit Testing: Added unit test for untested code in CheckBufferOverrun. Using memset on struct. 2010-04-05 21:50:40 +02:00
Reijo Tomperi d3c251f53a Refactor and fix "After a strncpy() the buffer should be zero-terminated" checking, 2010-04-05 21:47:50 +03:00
Daniel Marjamäki 6327ed55a2 Unit Testing: Buffer overruns when using memchr/memset/memcpy/etc 2010-04-05 20:02:28 +02:00
Daniel Marjamäki 0cad22314e Reverted 'astyle fix'. Those changes are not in sync with my astyle configuration/setup. 2010-04-02 07:30:58 +02:00
Martin Ettl 193aa7d1d3 astyle fix 2010-04-02 02:21:53 +02:00
Reijo Tomperi c7d36b73ed Fix #1548 (False positive: array index out of bounds in for-loop)
http://sourceforge.net/apps/trac/cppcheck/ticket/1548
2010-04-01 22:35:36 +03:00
Robert Reif 32e597e343 Fixed #1539 (False positive: possible error Array index out of bounds) 2010-03-30 17:33:17 +02:00
Robert Reif 0bddd1977f Fixed #1536 (###### If you see this, there is a bug ###### Token::Match() - varid was 0) 2010-03-29 17:25:38 +02:00
Robert Reif 62d2845014 Fixed #1492 (false negatives: array index out of bounds) 2010-03-28 15:56:13 +02:00
Robert Reif c50469dba6 Fixed #1523 (false negative:: buffer access out of bounds when using shift operator) 2010-03-27 07:21:08 +01:00
Reijo Tomperi 88840e6a08 Fix #1453 (possible infinite loop processing GNU Go's engine/montecarlo.c)
http://sourceforge.net/apps/trac/cppcheck/ticket/1453
2010-02-27 23:47:56 +02:00
Daniel Marjamäki 8f4edb5e45 Fixed #1409 (False positive: Buffer access out-of-bounds with strncpy and an array in typedef'ed struct) 2010-02-21 15:23:50 +01:00
Reijo Tomperi e44f0b1b8d Fix #1392 (Segfault in CheckBufferOverrun::checkScope)
http://sourceforge.net/apps/trac/cppcheck/ticket/1392
2010-02-15 23:20:09 +02:00
Monika Lukow e9e5174797 Fixed #1333 (Detect access out of bounds 'for (i = 100; i > 0; --i) a[i] = 0;') 2010-02-14 23:10:15 +01:00
Reijo Tomperi 2a78637da7 Fix #1340 (False positive: Array out of bounds for re-initialised array pointer)
http://sourceforge.net/apps/trac/cppcheck/ticket/1340
2010-02-10 23:11:08 +02:00
Reijo Tomperi 9852ab86e9 Fix #1358 (False negative: out-of-bounds not found near return)
http://sourceforge.net/apps/trac/cppcheck/ticket/1358
2010-02-05 23:55:10 +02:00
Reijo Tomperi db2aff03c7 Added test case for #1333 (Detect access out of bounds 'for (i = 100; i > 0; --i) a[i] = 0;')
http://sourceforge.net/apps/trac/cppcheck/ticket/1333
2010-01-31 22:02:26 +02:00
Daniel Marjamäki c666a9662b BufferOverrun: negative index is out of bounds 2010-01-11 21:18:07 +01:00
Daniel Marjamäki 57d1da3910 Ticket #1228 : Handle tokensBack in the Token class. When adding&removing tokens the Token class can make sure that this pointer is updated accordingly. It is very important that the tokensBack has the same scope as the token list, otherwise there will be a dead pointer problem. 2010-01-06 20:19:27 +01:00
Daniel Marjamäki e6d5c76138 refactoring 2010-01-03 15:52:52 +01:00
Daniel Marjamäki 79223b71d5 added test case for #1193 (false negative: array out of bounds in loop when there is calculation) 2010-01-03 15:49:17 +01:00
Daniel Marjamäki 5925b88b38 Robert Reif: improve check: array index out of bounds, show name of array, array size and array index 2009-12-25 15:25:58 +01:00
Daniel Marjamäki 8a1940e043 astyle 2009-12-19 17:57:58 +01:00
Daniel Marjamäki 0da0b5ffed ericsesterhenn: Fixed #1106 (check if buffer is zero terminated after a strncpy) 2009-12-18 17:26:15 +01:00
Daniel Marjamäki 0b09c36851 Fixed #1026 (false positive: buffer access out of bounds) 2009-12-05 11:41:30 +01:00
Martin Ettl 03e7914c98 partial fix of ticket #997; added check for write() two testcases 2009-11-28 13:41:24 +01:00
Daniel Marjamäki f75c9619d1 Fixed #1021 (Out-of-bounds access false positive) 2009-11-28 12:51:23 +01:00
Reijo Tomperi 12a87fa3a4 Fix #1007 (False positive array index out of bounds concerning a switch statement in a for loop)
Bailout if switch is found in for loop.
http://sourceforge.net/apps/trac/cppcheck/ticket/1007
2009-11-25 22:40:51 +02:00
Reijo Tomperi 9bdf4502ed Fix #995 (false positive: buffer access out of bounds when using fgets)
http://sourceforge.net/apps/trac/cppcheck/ticket/995
2009-11-21 15:45:52 +02:00
Reijo Tomperi 6417704577 Fix #985 (Detect buffer overrun with read())
http://sourceforge.net/apps/trac/cppcheck/ticket/985
2009-11-20 23:47:06 +02:00
Reijo Tomperi 9275b49688 Fix #964 (Integer division by zero exception)
http://sourceforge.net/apps/trac/cppcheck/ticket/964
2009-11-15 17:44:30 +02:00
Slava Semushin 6669a50634 Fixed #842 (out of bounds: when buffer is allocated with malloc)
http://sourceforge.net/apps/trac/cppcheck/ticket/842
2009-11-15 18:38:57 +06:00
Slava Semushin 3911dd79cb Fixed #900 (Improve out-of-bounds check to detect error with "new char(x)")
http://sourceforge.net/apps/trac/cppcheck/ticket/900
2009-11-15 18:04:17 +06:00
Reijo Tomperi 3d5760b149 Fix #947 (Errors not detected when size_t is used instead of int)
http://sourceforge.net/apps/trac/cppcheck/ticket/947
2009-11-12 23:31:13 +02:00
Reijo Tomperi 0518eed937 Fix #946 (False positive: Buffer access out-of-bounds)
http://sourceforge.net/apps/trac/cppcheck/ticket/946
2009-11-12 23:24:44 +02:00
Daniel Marjamäki 1fe94d74b8 unit testing: minor syntax fixes 2009-11-09 20:34:36 +01:00
Daniel Marjamäki 52eb32eb5b testbufferoverrun.cpp: fixed unit test error 2009-11-07 19:59:03 +01:00
Daniel Marjamäki 3b9b3b241e testbufferoverrun.cpp: minor updates to make it work better as extracted code 2009-11-07 19:51:18 +01:00
Daniel Marjamäki 3bd36226d6 testbufferoverrun: minor updates to make the code more easily compilable 2009-11-07 18:03:33 +01:00
Reijo Tomperi b222ef89be Fix #903 (false positive: buffer access out of bounds)
http://sourceforge.net/apps/trac/cppcheck/ticket/903
2009-11-07 00:58:33 +02:00
Daniel Marjamäki 77b676937d cleanup in testbufferoverrun.cpp 2009-11-06 19:15:59 +01:00
Reijo Tomperi 504ae8e22d Fix #868 (False positive - buffer access out of bounds in for loop)
http://sourceforge.net/apps/trac/cppcheck/ticket/868
2009-10-29 16:04:23 +02:00
Reijo Tomperi 9db22d9b48 Modify CheckBufferOverrun::checkGlobalAndLocalVariable() to use varid only.
Also add some TODO test cases.
2009-10-28 22:42:54 +02:00
Reijo Tomperi 0e695ea527 Test case for #863 (false positive memset array of pointers)
http://sourceforge.net/apps/trac/cppcheck/ticket/863
2009-10-27 20:54:35 +02:00
Daniel Marjamäki 09859c1019 refactoring the folder structure 2009-10-25 12:49:06 +01:00
Reijo Tomperi 6fbf873d25 Improved countSprintfLength() to detect more errors with %d.
Fixed some errors from test cases.
Added more test cases.
2009-10-20 00:48:29 +03:00
Reijo Tomperi aca743c9ed Fix #826 (False positive: sprintf with "f%s")
http://sourceforge.net/apps/trac/cppcheck/ticket/826
2009-10-18 13:58:48 +03:00
Daniel Marjamäki 01af70cc88 Fixed #823 (Buffer overrun with memcpy) 2009-10-15 19:36:48 +02:00
Reijo Tomperi be90d34962 Buffer overrun errors behind function call should be possible errors. 2009-10-14 00:09:37 +03:00
Reijo Tomperi 3dc45903bc Move buffer overrun errors behind --all
Fix one possible error issue with arrayindexoutofbounds
Make sure that possible errors are not shown without --all
2009-10-13 23:33:41 +03:00
Reijo Tomperi 4036dd5eff arrayIndexOutOfBounds check is now done without --all
Errors with buf[1] are still listed only with --all due to false positive risk in them.
2009-10-13 22:39:51 +03:00
Reijo Tomperi b6999d010f Fix #812 (False positive: sprintf with "%.4s" with --all)
http://sourceforge.net/apps/trac/cppcheck/ticket/812
2009-10-11 22:07:18 +03:00
Reijo Tomperi 59aad35137 Fix #694 (False (possible error) Buffer overrun with %-1s)
ashim2009 did most of the work
http://sourceforge.net/apps/trac/cppcheck/ticket/694
2009-10-11 21:36:22 +03:00
Reijo Tomperi a078c9353d More test cases for sprintf counter 2009-10-08 17:36:00 +03:00
Reijo Tomperi 5eee9af974 sprintf counter improvements 2009-10-08 16:27:46 +03:00
Reijo Tomperi 52ca36a6ed Added more test cases for sprintf counter 2009-10-07 21:33:44 +03:00
Daniel Marjamäki 13e43b8710 Ashim Kapoor: updated the counter (#694) 2009-10-07 18:21:44 +02:00
Reijo Tomperi fcd269dbf7 Refactoring: Moved some code into a new function.
Renamed count->countSprintfLength.
Added code to collect sprintf parameters.
Added a few TODO test cases.
2009-10-07 15:37:20 +03:00
Reijo Tomperi d598bed1c6 Fix #575 (Array index out of bounds check: get address of one-past-the-end array is legal)
http://sourceforge.net/apps/trac/cppcheck/ticket/575
2009-10-06 14:50:27 +03:00
Reijo Tomperi 1eba4b374f Fix #794 (Floating point exception on CheckBufferOverrun)
http://sourceforge.net/apps/trac/cppcheck/ticket/794
2009-10-05 23:19:44 +03:00
Reijo Tomperi 4650e513e1 Fix #741 (False positive: Buffer overrun with -a when index increased in multiple locations)
http://sourceforge.net/apps/trac/cppcheck/ticket/741
2009-10-01 11:33:53 +03:00
Reijo Tomperi d4a97eb2b4 Fix #419 (missleading buffer overrun)
http://sourceforge.net/apps/trac/cppcheck/ticket/419
2009-10-01 10:59:27 +03:00
Reijo Tomperi ec44f8f6c7 Fix #744 (False positive: (possible error) Array index out of bounds)
http://sourceforge.net/apps/trac/cppcheck/ticket/744
2009-09-30 15:51:33 +03:00
Daniel Marjamäki e5bc4a02ae added a TODO_ASSERT_EQUALS for the counter 2009-09-29 20:50:22 +02:00
Reijo Tomperi 77d677dd59 TODO test case for count() added 2009-09-29 18:51:29 +03:00
Daniel Marjamäki 12b29e35ad Ashim Kapoor: deal with backspace better (#694) 2009-09-29 17:02:19 +02:00
Daniel Marjamäki a1e20290cd Refactoring the unit testing of format strings 2009-09-27 22:13:15 +02:00
Slava Semushin e8c83613e4 Fixed #740 (False positive, buffer overrun with --all)
Regression since 07f41f4563 commit.

http://sourceforge.net/apps/trac/cppcheck/ticket/740
2009-09-27 22:50:59 +07:00
Slava Semushin 661ce78b69 Fixed #738 (False Buffer overrun with -a when i is increased by more than 1 inside loop body)
http://sourceforge.net/apps/trac/cppcheck/ticket/738
2009-09-27 22:14:51 +07:00
Reijo Tomperi fdde2182b9 Fix GPL comments in all files. ">." was missing from the end. 2009-09-27 18:08:31 +03:00
Slava Semushin 07f41f4563 Fixed #714 (False Buffer overrun with -a when i is increased by more than 1 in a loop)
http://sourceforge.net/apps/trac/cppcheck/ticket/714
2009-09-27 21:12:46 +07:00
Slava Semushin acdbb20c99 Detect buffer overruns when ?: use as sprintf() argument. 2009-09-27 00:40:58 +07:00
Slava Semushin 19ed8e9311 Fixed #729 (False positive: Buffer overrun when ? is used to select parameter)
http://sourceforge.net/apps/trac/cppcheck/ticket/729
2009-09-27 00:06:54 +07:00
Slava Semushin 50a34b8a37 Fixed #731 (False positive, strcpy copying a buffer with a null character)
http://sourceforge.net/apps/trac/cppcheck/ticket/731
2009-09-26 22:58:14 +07:00
Daniel Marjamäki 3da779725d Ashim Kapoor: handle %i,%f,%d,%x,%X better (#694) 2009-09-26 16:19:18 +02:00
Reijo Tomperi 6a63742dde Fix #730 (False positive, buffer overrun with strncpy)
http://sourceforge.net/apps/trac/cppcheck/ticket/730
2009-09-25 23:32:18 +03:00
Daniel Marjamäki fe3c8cab9f Ashim Kapoor: Added function that returns minimum size of format strings (#694) 2009-09-25 18:23:44 +02:00
Slava Semushin 5dee65048f Fixed #690 (False positive: (possible error) Buffer overrun)
http://sourceforge.net/apps/trac/cppcheck/ticket/690
2009-09-20 17:54:19 +07:00
Slava Semushin a9273c9d39 Fixed #629 (Tokenizer: expand nested strcat() calls)
http://sourceforge.net/apps/trac/cppcheck/ticket/629
2009-09-05 23:46:27 +07:00
Slava Semushin c50f7787f9 Fixed #569 (Buffer overrun not detected when strcat() called few times)
http://sourceforge.net/apps/trac/cppcheck/ticket/569
2009-08-30 18:44:23 +07:00
Slava Semushin 7c86a10a9d Fixed #617 (False positive "buffer overrun" when sprintf() doesn't have optional parameters)
http://sourceforge.net/apps/trac/cppcheck/ticket/617
2009-08-27 00:21:32 +07:00
Slava Semushin 0f96299d87 Fixed ticket #570 (Buffer overrun not detected when sprintf() format string greater then buffer size)
http://sourceforge.net/apps/trac/cppcheck/ticket/570
2009-08-08 21:52:35 +07:00
Slava Semushin 92d4c086ce Fixed ticket #571 (Buffer overrun for sprintf() not detected after first ')' symbol)
http://sourceforge.net/apps/trac/cppcheck/ticket/571
2009-08-08 21:03:10 +07:00
Slava Semushin 822fb93cda Improved "index out of bounds" check.
Corrected 342acaaaf2 commit.
2009-08-02 19:29:45 +07:00
Slava Semushin f38530fb31 test/testbufferoverrun.cpp: improve test cases. 2009-08-02 19:29:37 +07:00
Slava Semushin 342acaaaf2 Fixed #547 (index out of bounds not detected when addition used as array index)
http://sourceforge.net/apps/trac/cppcheck/ticket/547
2009-08-02 14:59:02 +07:00
Slava Semushin 6c022798ea Fixed ticket #499 (buffer overflow not detected when using macros)
sprintf() buffer overrun detection works wrong due to typo (since time
when it was added in commit a604f56f19).

Also reports buffer overrun when sprintf() writes bytes equal to
buffer size -- in this case off-by-one error appears.

http://sourceforge.net/apps/trac/cppcheck/ticket/499
2009-07-26 19:29:46 +07:00
Daniel Marjamäki 18f9e05f5a refactoring: Renamed checking classes 2009-07-13 16:00:15 +02:00
Daniel Marjamäki 7d35447d80 refactoring: renamed the severity "all" to "possible error" 2009-07-13 10:16:31 +02:00
Daniel Marjamäki 36896e1ca0 better description for the message with id strncatUsage 2009-07-11 12:16:38 +02:00
Reijo Tomperi 751a31ed91 Fix ticket #445 (simple to avoid false positive for buffer overflow)
http://sourceforge.net/apps/trac/cppcheck/ticket/445
Simple bailout in case "if" is found inside the for-loop.
2009-06-30 00:42:46 +03:00
Slava Semushin 4dd3835617 Embed errout.str() into ASSERT_EQUALS() call.
Get rid of useless variables.

No functional change.
2009-06-14 13:33:44 +07:00
Slava Semushin 58781c761c Fixed ticket #329 (snprintf size is out of bounds when two variables in one scope with similar names)
FIXME:
Because it's fix for simplifyTokenList() test should be moved to
test/testsimplifytokens.cpp file.

http://apps.sourceforge.net/trac/cppcheck/ticket/329
2009-06-05 09:53:34 +07:00
Slava Semushin 52a8368b02 Strip redundant std::string usage from tests.
Second round: handle empty strings.

Done by command:
git grep -l ASSERT_EQUALS | xargs sed -i 's|ASSERT_EQUALS(std::string(\(".*"\)),|ASSERT_EQUALS(\1,|'

Should be no functional change.
2009-06-05 07:43:55 +07:00
Daniel Marjamäki b4c637c58b Fixed #350 (False positive: Array index out of bounds) 2009-06-02 18:56:53 +02:00
Daniel Marjamäki 6ef87e8eab Fixed #339 (Buffer overrun not detected with pointer arrays)
http://apps.sourceforge.net/trac/cppcheck/ticket/339
2009-06-01 19:21:08 +02:00
Slava Semushin e5c0383594 Strip redundant std::string usage from tests.
Done by command:
git grep -l ASSERT_EQUALS | xargs sed -i 's|ASSERT_EQUALS(std::string(\(".\+"\)),|ASSERT_EQUALS(\1,|'

Should be no functional change.
2009-06-01 02:50:25 +07:00
Reijo Tomperi 58eda6e978 Fix ticket #325 (Replace developer names in source files with AUTHORS file)
http://apps.sourceforge.net/trac/cppcheck/ticket/325
2009-05-30 08:48:12 +03:00
Reijo Tomperi 11858129d0 Fix ticket #243 (boundary checking)
http://apps.sourceforge.net/trac/cppcheck/ticket/243
2009-04-04 21:05:48 +03:00
Daniel Marjamäki b9f4a773b8 Buffer overrun: Added check to detect when size argument to memset is a char constant (#213) 2009-03-25 07:25:10 +01:00
Daniel Marjamäki 6580e0eb21 fixed snprintf false positive (#210) 2009-03-24 18:43:39 +01:00
Daniel Marjamäki 21dff96e7b refactoring checkbufferoverrun 2009-03-20 17:35:53 +01:00
Daniel Marjamäki 0cc7672673 Fixed Ticket #82 (detect buffer overrun; dynamic memory) 2009-03-16 18:11:09 +01:00
Reijo Tomperi fc8f47145a Copyrights updated 2009-03-01 19:52:33 +00:00
Daniel Marjamäki dddfc50dff Reverted changes made in [1289] 2009-02-27 07:50:39 +00:00
Daniel Marjamäki 91011b8450 array index out of bounds: Added todo test case TestBufferOverrun::array_index_13 for ticket #118 2009-02-26 19:46:59 +00:00
Daniel Marjamäki 08f76279ed buffer overrun: catch cases when using cin to read to a char array 2009-02-21 12:22:04 +00:00
Daniel Marjamäki ed86d924df buffer overrun: dangerous usage of strncpy+strncat 2009-02-20 21:16:07 +00:00
Daniel Marjamäki 15e86db3ed buffer overrun: Added checking of strncat 2009-02-20 21:00:59 +00:00
Daniel Marjamäki 0e1ef1f45f added todo testcases for strncat checking 2009-02-20 20:00:49 +00:00
Daniel Marjamäki 4f121daca4 buffer overruns: added simple support for initialized array 2009-02-12 19:11:52 +00:00
Daniel Marjamäki ba3752feb6 buffer overrun: improved checking of global variables 2009-02-11 16:12:29 +00:00
Reijo Tomperi 4660b7648d Moved stloutofbounds check to CheckStl class. 2009-02-10 19:56:00 +00:00
Reijo Tomperi 9dff3f4c52 Fix ticket #94 (STL container overrun). Check is currently behind --all 2009-02-09 22:25:44 +00:00
Reijo Tomperi b211b8cbe8 Fix ticket #84 (unit testing: use "protected" instead of preprocessor) 2009-02-07 20:06:00 +00:00
Reijo Tomperi a06861948b Fixed: Ticket #78 Change (always) into (error) in error messages 2009-02-05 21:06:32 +00:00
Daniel Marjamäki d73e6c398f testbufferoverrun: activated test 2009-02-04 16:58:44 +00:00
Daniel Marjamäki 27c0f786bc tokenizer: improved sizeof handling 2009-02-02 17:27:34 +00:00
Daniel Marjamäki 3457b38d7a errmsg: write severity in the message 2009-01-31 08:33:31 +00:00
Daniel Marjamäki 7d98c74d40 added test case TestBufferOverrun::sizeof2 2009-01-30 06:11:31 +00:00
Daniel Marjamäki b7b055e885 tokenizer: fixed TestTokenizer::sizeof1 2009-01-28 17:38:32 +00:00
Daniel Marjamäki 12b6cf8c70 bad sizeof handling 2009-01-28 05:31:26 +00:00
Leandro Penz 835a749026 snprintf: more tests. 2009-01-24 18:55:07 +00:00
Reijo Tomperi 176dd41306 Fixed Ticket #40, Check copyright texts in files, now that we have new developers. 2009-01-21 20:04:20 +00:00
Daniel Marjamäki 8780fbf8bb bounds checking: Added error message "snprintf size is out of bounds" 2009-01-17 13:09:02 +00:00
Daniel Marjamäki a604f56f19 buffer overruns: added sprintf checking 2009-01-14 06:29:35 +00:00
Reijo Tomperi e435a1f1d6 Refactoring: Added src/ and test/ folders. Moved source files to those folders, updated makefile and codeblocks project file. 2009-01-06 14:18:36 +00:00