Skip to content

Commit 3a66fd7

Browse files
committed
C++: Add FP test.
1 parent 49d6d3f commit 3a66fd7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-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:455:12:455:17 | call to sscanf | 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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,16 @@ void bad_check() {
446446
}
447447
use(i); // GOOD [FALSE POSITIVE]: Technically no security issue, but code is incorrect.
448448
}
449+
}
450+
451+
#define EOF (-1)
452+
453+
void disjunct_boolean_condition(const char* modifier_data) {
454+
long value;
455+
auto rc = sscanf(modifier_data, "%lx", &value);
456+
457+
if((rc == EOF) || (rc == 0)) {
458+
return;
459+
}
460+
use(value); // GOOD
449461
}

0 commit comments

Comments
 (0)