Skip to content

Commit 40cc2e7

Browse files
committed
C++: Also exclude unevaluated buffers in 'OverflowStatic'.
1 parent 4d2a1ea commit 40cc2e7

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cpp/ql/src/Critical/OverflowStatic.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import LoopBounds
2222
private predicate staticBufferBase(VariableAccess access, Variable v) {
2323
v.getType().(ArrayType).getBaseType() instanceof CharType and
2424
access = v.getAnAccess() and
25-
not memberMayBeVarSize(_, v)
25+
not memberMayBeVarSize(_, v) and
26+
not access.isUnevaluated()
2627
}
2728

2829
predicate staticBuffer(VariableAccess access, Variable v, int size) {

cpp/ql/test/query-tests/Critical/OverflowStatic/OverflowStatic.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
| test.cpp:24:27:24:27 | 4 | Potential buffer-overflow: 'buffer1' has size 3 not 4. |
1515
| test.cpp:26:27:26:27 | 4 | Potential buffer-overflow: 'buffer2' has size 3 not 4. |
1616
| test.cpp:40:22:40:27 | amount | Potential buffer-overflow: 'buffer' has size 100 not 101. |
17-
| test.cpp:62:33:62:43 | access to array | Potential buffer-overflow: 'buffer' has size 100 but 'buffer[101]' may be accessed here. |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ void f3() {
5959

6060
int unevaluated_test() {
6161
char buffer[100];
62-
return sizeof(buffer) / sizeof(buffer[101]); // GOOD [FALSE POSITIVE]
62+
return sizeof(buffer) / sizeof(buffer[101]); // GOOD
6363
}

0 commit comments

Comments
 (0)