diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected index 2a9b25cb541..651dd4d1ac8 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected @@ -1,5 +1,10 @@ edges -| overflowdestination.cpp:27:9:27:12 | argv | overflowdestination.cpp:30:17:30:20 | (const char *)... | +| main.cpp:7:33:7:36 | argv | main.cpp:7:33:7:36 | argv | +| main.cpp:7:33:7:36 | argv | main.cpp:7:33:7:36 | argv indirection | +| main.cpp:7:33:7:36 | argv | overflowdestination.cpp:23:45:23:48 | argv | +| main.cpp:7:33:7:36 | argv indirection | overflowdestination.cpp:23:45:23:48 | *argv | +| overflowdestination.cpp:23:45:23:48 | *argv | overflowdestination.cpp:30:17:30:20 | (const char *)... | +| overflowdestination.cpp:23:45:23:48 | argv | overflowdestination.cpp:30:17:30:20 | (const char *)... | | overflowdestination.cpp:43:8:43:10 | fgets output argument | overflowdestination.cpp:46:15:46:17 | (const void *)... | | overflowdestination.cpp:50:52:50:54 | *src | overflowdestination.cpp:50:52:50:54 | ReturnIndirection | | overflowdestination.cpp:50:52:50:54 | src | overflowdestination.cpp:53:15:53:17 | (const void *)... | @@ -17,7 +22,11 @@ edges | overflowdestination.cpp:76:30:76:32 | src | overflowdestination.cpp:57:52:57:54 | src | | overflowdestination.cpp:76:30:76:32 | src indirection | overflowdestination.cpp:57:52:57:54 | *src | nodes -| overflowdestination.cpp:27:9:27:12 | argv | semmle.label | argv | +| main.cpp:7:33:7:36 | argv | semmle.label | argv | +| main.cpp:7:33:7:36 | argv | semmle.label | argv | +| main.cpp:7:33:7:36 | argv indirection | semmle.label | argv indirection | +| overflowdestination.cpp:23:45:23:48 | *argv | semmle.label | *argv | +| overflowdestination.cpp:23:45:23:48 | argv | semmle.label | argv | | overflowdestination.cpp:30:17:30:20 | (const char *)... | semmle.label | (const char *)... | | overflowdestination.cpp:43:8:43:10 | fgets output argument | semmle.label | fgets output argument | | overflowdestination.cpp:46:15:46:17 | (const void *)... | semmle.label | (const void *)... | @@ -37,7 +46,7 @@ nodes subpaths | overflowdestination.cpp:75:30:75:32 | src indirection | overflowdestination.cpp:50:52:50:54 | *src | overflowdestination.cpp:50:52:50:54 | ReturnIndirection | overflowdestination.cpp:75:30:75:32 | overflowdest_test2 output argument | #select -| overflowdestination.cpp:30:2:30:8 | call to strncpy | overflowdestination.cpp:27:9:27:12 | argv | overflowdestination.cpp:30:17:30:20 | (const char *)... | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | +| overflowdestination.cpp:30:2:30:8 | call to strncpy | main.cpp:7:33:7:36 | argv | overflowdestination.cpp:30:17:30:20 | (const char *)... | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | | overflowdestination.cpp:46:2:46:7 | call to memcpy | overflowdestination.cpp:43:8:43:10 | fgets output argument | overflowdestination.cpp:46:15:46:17 | (const void *)... | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | | overflowdestination.cpp:53:2:53:7 | call to memcpy | overflowdestination.cpp:73:8:73:10 | fgets output argument | overflowdestination.cpp:53:15:53:17 | (const void *)... | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | | overflowdestination.cpp:64:2:64:7 | call to memcpy | overflowdestination.cpp:73:8:73:10 | fgets output argument | overflowdestination.cpp:64:16:64:19 | (const void *)... | To avoid overflow, this operation should be bounded by destination-buffer size, not source-buffer size. | diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/main.cpp b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/main.cpp new file mode 100644 index 00000000000..78f94af22cf --- /dev/null +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/main.cpp @@ -0,0 +1,12 @@ +int overflowdesination_main(int argc, char **argv); +int test_buffer_overrun_main(int argc, char **argv); +int tests_restrict_main(int argc, char **argv); +int tests_main(int argc, char **argv); + +int main(int argc, char **argv) { + overflowdesination_main(argc, argv); + test_buffer_overrun_main(argc, argv); + tests_restrict_main(argc, argv); + tests_main(argc, argv); + return 0; +} diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/overflowdestination.cpp b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/overflowdestination.cpp index 2a939f83a73..8b785b5a662 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/overflowdestination.cpp +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/overflowdestination.cpp @@ -20,7 +20,7 @@ inline size_t min(size_t a, size_t b) { } } -int main(int argc, char* argv[]) { +int overflowdesination_main(int argc, char* argv[]) { char param[20]; char *arg1; diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/test_buffer_overrun.cpp b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/test_buffer_overrun.cpp index d05ed0c94a7..8554f8c62fb 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/test_buffer_overrun.cpp +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/test_buffer_overrun.cpp @@ -29,7 +29,7 @@ void test_buffer_overrun_in_while_loop_using_array_indexing() } } -int main(int argc, char *argv[]) +int test_buffer_overrun_main(int argc, char *argv[]) { test_buffer_overrun_in_for_loop(); test_buffer_overrun_in_while_loop_using_pointer_arithmetic(); diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp index 668324e7963..42c06043927 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests.cpp @@ -603,7 +603,7 @@ void test22(bool b, const char* source) { memcpy(dest, source, n); // GOOD } -int main(int argc, char *argv[]) +int tests_main(int argc, char *argv[]) { long long arr17[19]; diff --git a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests_restrict.c b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests_restrict.c index 9b6990db535..96a5571bf65 100644 --- a/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests_restrict.c +++ b/cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/tests_restrict.c @@ -12,7 +12,7 @@ void test1() memcpy(largebuf, smallbuf, 2); // BAD: source over-read } -int main(int argc, char *argv[]) +int tests_restrict_main(int argc, char *argv[]) { test1();