C++: using buildin offsetof for an array member indexed after end is legal

This commit is contained in:
Anders Fugmann
2021-09-23 13:35:43 +02:00
parent b08eabec68
commit 3e5f7d0db5

View File

@@ -130,7 +130,9 @@ predicate outOfBounds(BufferAccess bufaccess, string msg) {
(
access > size
or
access = size and not exists(AddressOfExpr addof | bufaccess = addof.getOperand())
access = size and
not exists(AddressOfExpr addof | bufaccess = addof.getOperand()) and
not exists(BuiltInOperationBuiltInOffsetOf offsetof | offsetof.getAChild() = bufaccess)
) and
msg =
"Potential buffer-overflow: '" + buf + "' has size " + size.toString() + " but '" + buf + "[" +