Skip to content

Commit 3e9aeac

Browse files
committed
CPP: Fix sscanf false positives in older linux repos
1 parent 9eb5b23 commit 3e9aeac

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

cpp/ql/src/Critical/IncorrectCheckScanf.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ import ScanfChecks
1919

2020
from ScanfFunctionCall call
2121
where incorrectlyCheckedScanf(call)
22-
select call, "The result of scanf is onyl checkeck against 0, but it can also return EOF."
22+
select call, "The result of scanf is only checked against 0, but it can also return EOF."

cpp/ql/src/Critical/ScanfChecks.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ private predicate exprInBooleanContext(Expr e) {
2222
}
2323

2424
private predicate isLinuxKernel() {
25-
exists(Macro macro | macro.getName() = "_LINUX_KERNEL_SPRINTF_H_")
25+
// For the purpose of sscanf, we check the header guards for the files that it is defined in (which have changed)
26+
exists(Macro macro | macro.getName() in ["_LINUX_KERNEL_SPRINTF_H_", "_LINUX_KERNEL_H"])
2627
}
2728

2829
/**
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| test.cpp:162:7:162:11 | call to scanf | The result of scanf is onyl checkeck against 0, but it can also return EOF. |
2-
| test.cpp:171:7:171:11 | call to scanf | The result of scanf is onyl checkeck against 0, but it can also return EOF. |
3-
| test.cpp:204:7:204:11 | call to scanf | The result of scanf is onyl checkeck against 0, but it can also return EOF. |
4-
| test.cpp:436:7:436:11 | call to scanf | The result of scanf is onyl checkeck against 0, but it can also return EOF. |
5-
| test.cpp:443:11:443:15 | call to scanf | The result of scanf is onyl checkeck against 0, but it can also return EOF. |
1+
| test.cpp:162:7:162:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
2+
| test.cpp:171:7:171:11 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |
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+
| 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+
| test.cpp:443:11:443:15 | call to scanf | The result of scanf is only checked against 0, but it can also return EOF. |

0 commit comments

Comments
 (0)