Do not use arrays in function parameter types #4452
Labels
api-break
This issue/PR breaks the API and must wait for a new major version
component-crypto
Crypto primitives and low-level interfaces
size-s
Estimated task size: small (~2d)
Context and rationale
A few functions in the API have a parameter of array type. Array types are equivalent to pointers in function parameters as far as the C language is concerned: the array size is purely indicative. However, static analyzers including compilers don't always see it that way and may treat the array size as meaningful.
See #4130 for why this is a problem. Popular compilers are increasingly likely to complain that
mbedtls_sha512_finish
should not output to a 48-byte buffer, even when it's calculating a SHA-384 hash, because its output is declared asunsigned char[64]
.Proposal
Change array types in API function parameters to pointers.
Work items for 3.0
sha512_finish
, which is the only case I'm aware of that is a problem in practice.Work items for 3.x
Work items for 4.0
Since low-level crypto APIs are becoming private, only one public headers still has array parameters:
ssl.h
. Let's remove those.The text was updated successfully, but these errors were encountered: