mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
C++: Add new test cases for cpp/incorrectly-checked-scanf.
This commit is contained in:
@@ -3,3 +3,5 @@
|
||||
| test.cpp:204:7:204:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
|
||||
| test.cpp:436:7:436:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
|
||||
| test.cpp:443:11:443:15 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
|
||||
| test.cpp:501:13:501:17 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
|
||||
| test.cpp:512:13:512:17 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
|
||||
|
||||
@@ -37,6 +37,8 @@ edges
|
||||
| test.cpp:420:19:420:20 | scanf output argument | test.cpp:423:7:423:7 | i | provenance | |
|
||||
| test.cpp:455:41:455:46 | sscanf output argument | test.cpp:460:6:460:10 | value | provenance | |
|
||||
| test.cpp:467:20:467:25 | scanf output argument | test.cpp:474:6:474:10 | value | provenance | |
|
||||
| test.cpp:480:25:480:26 | scanf output argument | test.cpp:484:9:484:9 | i | provenance | |
|
||||
| test.cpp:491:25:491:26 | scanf output argument | test.cpp:495:8:495:8 | i | provenance | |
|
||||
nodes
|
||||
| test.cpp:34:15:34:16 | scanf output argument | semmle.label | scanf output argument |
|
||||
| test.cpp:35:7:35:7 | i | semmle.label | i |
|
||||
@@ -114,6 +116,10 @@ nodes
|
||||
| test.cpp:460:6:460:10 | value | semmle.label | value |
|
||||
| test.cpp:467:20:467:25 | scanf output argument | semmle.label | scanf output argument |
|
||||
| test.cpp:474:6:474:10 | value | semmle.label | value |
|
||||
| test.cpp:480:25:480:26 | scanf output argument | semmle.label | scanf output argument |
|
||||
| test.cpp:484:9:484:9 | i | semmle.label | i |
|
||||
| test.cpp:491:25:491:26 | scanf output argument | semmle.label | scanf output argument |
|
||||
| test.cpp:495:8:495:8 | i | semmle.label | i |
|
||||
subpaths
|
||||
#select
|
||||
| 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 |
|
||||
@@ -134,3 +140,5 @@ subpaths
|
||||
| test.cpp:423:7:423:7 | i | test.cpp:420:19:420:20 | scanf output argument | test.cpp:423:7:423: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:420:7:420:11 | call to scanf | call to scanf |
|
||||
| test.cpp:460:6:460:10 | value | test.cpp:455:41:455:46 | sscanf output argument | test.cpp:460:6:460:10 | value | 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:455:12:455:17 | call to sscanf | call to sscanf |
|
||||
| test.cpp:474:6:474:10 | value | test.cpp:467:20:467:25 | scanf output argument | test.cpp:474:6:474:10 | value | 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:467:8:467:12 | call to scanf | call to scanf |
|
||||
| test.cpp:484:9:484:9 | i | test.cpp:480:25:480:26 | scanf output argument | test.cpp:484:9:484:9 | 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:480:13:480:17 | call to scanf | call to scanf |
|
||||
| test.cpp:495:8:495:8 | i | test.cpp:491:25:491:26 | scanf output argument | test.cpp:495:8:495:8 | 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:491:13:491:17 | call to scanf | call to scanf |
|
||||
|
||||
@@ -472,4 +472,49 @@ void check_for_negative_test() {
|
||||
return;
|
||||
}
|
||||
use(value);
|
||||
}
|
||||
}
|
||||
|
||||
void multiple_checks() {
|
||||
{
|
||||
int i;
|
||||
int res = scanf("%d", &i);
|
||||
|
||||
if (res >= 0) {
|
||||
if (res != 0) {
|
||||
use(i); // GOOD: checks return value [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
int res = scanf("%d", &i);
|
||||
|
||||
if (res < 0) return;
|
||||
if (res != 0) {
|
||||
use(i); // GOOD: checks return value [FALSE POSITIVE]
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
int res = scanf("%d", &i); // [FALSE POSITIVE]
|
||||
|
||||
if (res >= 1) {
|
||||
if (res != 0) {
|
||||
use(i); // GOOD: checks return value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int i;
|
||||
int res = scanf("%d", &i); // [FALSE POSITIVE]
|
||||
|
||||
if (res == 1) {
|
||||
if (res != 0) {
|
||||
use(i); // GOOD: checks return value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user