File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
cpp/ql/test/query-tests/Critical/MissingCheckScanf Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 3
3
| test.cpp:204:7:204:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
4
4
| test.cpp:436:7:436:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
5
5
| test.cpp:443:11:443:15 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
6
+ | test.cpp:467:8:467:12 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
Original file line number Diff line number Diff line change @@ -458,4 +458,18 @@ void disjunct_boolean_condition(const char* modifier_data) {
458
458
return ;
459
459
}
460
460
use (value); // GOOD
461
+ }
462
+
463
+ void check_for_negative_test () {
464
+ int res;
465
+ int value;
466
+
467
+ res = scanf (" %d" , &value); // GOOD [FALSE POSITIVE]
468
+ if (res == 0 ) {
469
+ return ;
470
+ }
471
+ if (res < 0 ) {
472
+ return ;
473
+ }
474
+ use (value);
461
475
}
You can’t perform that action at this time.
0 commit comments