mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
C++: Add tests.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
edges
|
||||
| test.c:10:31:10:32 | sscanf output argument | test.c:11:7:11:7 | x | provenance | |
|
||||
| test.cpp:34:15:34:16 | scanf output argument | test.cpp:35:7:35:7 | i | provenance | |
|
||||
| test.cpp:41:19:41:20 | scanf output argument | test.cpp:43:8:43:8 | i | provenance | |
|
||||
| test.cpp:58:19:58:20 | scanf output argument | test.cpp:60:8:60:8 | i | provenance | |
|
||||
@@ -56,6 +57,8 @@ edges
|
||||
| test.cpp:567:35:567:36 | scanf output argument | test.cpp:569:9:569:9 | i | provenance | |
|
||||
| test.cpp:575:30:575:31 | scanf output argument | test.cpp:577:9:577:9 | i | provenance | |
|
||||
nodes
|
||||
| test.c:10:31:10:32 | sscanf output argument | semmle.label | sscanf output argument |
|
||||
| test.c:11:7:11:7 | x | semmle.label | x |
|
||||
| test.cpp:34:15:34:16 | scanf output argument | semmle.label | scanf output argument |
|
||||
| test.cpp:35:7:35:7 | i | semmle.label | i |
|
||||
| test.cpp:41:19:41:20 | scanf output argument | semmle.label | scanf output argument |
|
||||
@@ -165,6 +168,7 @@ nodes
|
||||
| test.cpp:577:9:577:9 | i | semmle.label | i |
|
||||
subpaths
|
||||
#select
|
||||
| test.c:11:7:11:7 | x | test.c:10:31:10:32 | sscanf output argument | test.c:11:7:11:7 | x | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.c:10:13:10:18 | call to sscanf | call to sscanf |
|
||||
| test.cpp:35:7:35:7 | i | test.cpp:34:15:34:16 | scanf output argument | test.cpp:35:7:35:7 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:34:3:34:7 | call to scanf | call to scanf |
|
||||
| test.cpp:68:7:68:7 | i | test.cpp:67:15:67:16 | scanf output argument | test.cpp:68:7:68:7 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:67:3:67:7 | call to scanf | call to scanf |
|
||||
| test.cpp:80:7:80:7 | i | test.cpp:79:15:79:16 | scanf output argument | test.cpp:80:7:80:7 | i | This variable is read, but may not have been written. It should be guarded by a check that the $@ returns at least 1. | test.cpp:79:3:79:7 | call to scanf | call to scanf |
|
||||
|
||||
13
cpp/ql/test/query-tests/Critical/MissingCheckScanf/test.c
Normal file
13
cpp/ql/test/query-tests/Critical/MissingCheckScanf/test.c
Normal file
@@ -0,0 +1,13 @@
|
||||
# define likely(x) __builtin_expect(!!(x), 1)
|
||||
int sscanf(const char *s, const char *format, ...);
|
||||
|
||||
void use(int i);
|
||||
|
||||
void test_likely(const char* s, const char* format)
|
||||
{
|
||||
int x;
|
||||
|
||||
if (likely(sscanf(s, format, &x) == 1)) {
|
||||
use(x); // GOOD [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user