Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4820,6 +4820,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-null/>
<not-uninit/>
<strz/>
<minsize type="strlen" arg="2"/>
</arg>
<arg nr="2" direction="in">
<not-null/>
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/std.c
Original file line number Diff line number Diff line change
Expand Up @@ -3446,7 +3446,7 @@ void bufferAccessOutOfBounds_strcat(char *dest, const char * const source)
char buf4[4] = {0};
const char * const srcstr3 = "123";
const char * const srcstr4 = "1234";
// @todo #8599 cppcheck-suppress bufferAccessOutOfBounds
// cppcheck-suppress bufferAccessOutOfBounds
(void)strcat(buf4,srcstr4); // off by one issue: strcat is appends \0' at the end

// no warning shall be shown for
Expand Down
14 changes: 14 additions & 0 deletions test/testbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,20 @@ class TestBufferOverrun : public TestFixture {
" strcat(n, \"def\");\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Buffer is accessed out of bounds: n\n", "", errout_str());

check("void f()\n" // #12489
"{\n"
" char d[3] = {};\n"
" strcat(d, \"12345678\");\n"
"}");
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: d\n", errout_str());

check("void f()\n"
"{\n"
" char d[3] = \"ab\"; \n"
" strcat(d, \"c\");\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: d\n", "", errout_str());
}

void buffer_overrun_7() {
Expand Down