Skip to content

Commit 3e5f7d0

Browse files
committed
C++: using buildin offsetof for an array member indexed after end is legal
1 parent b08eabe commit 3e5f7d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cpp/ql/src/Critical/OverflowStatic.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ predicate outOfBounds(BufferAccess bufaccess, string msg) {
130130
(
131131
access > size
132132
or
133-
access = size and not exists(AddressOfExpr addof | bufaccess = addof.getOperand())
133+
access = size and
134+
not exists(AddressOfExpr addof | bufaccess = addof.getOperand()) and
135+
not exists(BuiltInOperationBuiltInOffsetOf offsetof | offsetof.getAChild() = bufaccess)
134136
) and
135137
msg =
136138
"Potential buffer-overflow: '" + buf + "' has size " + size.toString() + " but '" + buf + "[" +

0 commit comments

Comments
 (0)