Skip to content

Commit 11406b1

Browse files
author
Nikita Kraiouchkine
committed
Update OutOfBounds.qll
1 parent 8c30b0f commit 11406b1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

c/common/src/codingstandards/c/OutOfBounds.qll

+14-4
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,19 @@ module OutOfBounds {
727727
}
728728

729729
predicate problems(BufferAccessLibraryFunctionCall fc, string msg) {
730-
exists(Expr bufferUse, Expr bufferSize, Expr sizeSource, PointerToObjectSource sourceBufferAllocation, int s1, int s2 |
731-
isBufferSizeExprGreaterThanSourceSizeExpr(bufferUse, bufferSize, sizeSource, sourceBufferAllocation, s1, s2, fc) and
732-
msg = "test"
730+
exists(Expr bufferUse, PointerToObjectSource source |
731+
exists(int bufSize, int size, Expr bufferSize, Expr sizeSource |
732+
isBufferSizeExprGreaterThanSourceSizeExpr(bufferUse, bufferSize, sizeSource, source, bufSize, size, fc) and
733+
msg = "Buffer size is smaller than size arg."
734+
)
735+
or
736+
exists(int i |
737+
fc.getTarget().(BufferAccessLibraryFunction).getANullTerminatedParameterIndex(i) and
738+
fc.getArgument(i) = bufferUse and
739+
source.isNotNullTerminated() and
740+
hasFlowFromBufferOrSizeExprToUse(source, bufferUse.getAChild*()) and
741+
msg = "Buffer " + bufferUse.toString() + " is not null-terminated."
742+
)
733743
)
734744
}
735-
}
745+
}

0 commit comments

Comments
 (0)