Skip to content

Commit 7e29141

Browse files
committed
C++: Add FP test.
1 parent aeae208 commit 7e29141

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cpp/ql/test/query-tests/Critical/MissingCheckScanf/IncorrectCheckScanf.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
| test.cpp:204:7:204:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
44
| test.cpp:436:7:436:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
55
| 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. |

cpp/ql/test/query-tests/Critical/MissingCheckScanf/test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,18 @@ void disjunct_boolean_condition(const char* modifier_data) {
458458
return;
459459
}
460460
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);
461475
}

0 commit comments

Comments
 (0)