CodeQL queries 1.24
This rule finds expressions that take the size of a function parameter of array type.
In C, function parameters of array type are treated as if they had the corresponding pointer type,
so their size is always the size of the pointer type (typically either four or eight).
In particular, one cannot determine the size of a memory buffer passed as a parameter in this way.
sizeof operator on pointer types will produce unexpected results if the developer intended
to get the size of an array instead of the pointer.
Modify the function to take an extra argument indicating the buffer size.
- Comp.lang.c, Frequently Asked Questions: Question 6.3: So what is meant by the "equivalence of pointers and arrays" in C?.
- Common Weakness Enumeration: CWE-467.