mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: add false positives to MissingCheckScanf test
See https://github.com/github/codeql/issues/12412 for the initial report.
This commit is contained in:
@@ -19,3 +19,5 @@
|
||||
| test.cpp:302:8:302:12 | ptr_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:301:3:301:7 | call to scanf | call to scanf |
|
||||
| test.cpp:310:7:310: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:309:3:309:7 | call to scanf | call to scanf |
|
||||
| test.cpp:404:25:404:25 | u | 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:403:6:403:11 | call to sscanf | call to sscanf |
|
||||
| test.cpp:416:7:416: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:413:7:413:11 | call to scanf | call to scanf |
|
||||
| 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 |
|
||||
|
||||
@@ -406,3 +406,20 @@ char *my_string_copy() {
|
||||
*ptr++ = 0;
|
||||
return DST_STRING;
|
||||
}
|
||||
|
||||
void scan_and_write() {
|
||||
{
|
||||
int i;
|
||||
if (scanf("%d", &i) < 1) {
|
||||
i = 0;
|
||||
}
|
||||
use(i); // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
|
||||
}
|
||||
{
|
||||
int i;
|
||||
if (scanf("%d", &i) != 1) {
|
||||
i = 0;
|
||||
}
|
||||
use(i); // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user