New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix build failure on gcc-11 #3848
Fix build failure on gcc-11 #3848
Conversation
660dd9f
to
4a884a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a changelog entry file in ChangeLog.d
indicating that this fixes the build with GCC 11 and referencing #3782.
4a884a3
to
d84ebf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'm happy with the PR now except that I'd rather avoid wasting stack space for the sake of a compiler warning.
LTS branches should work under newer compilers too, so once we agree on the approach, this will need backports to |
d5dd793
to
72783c5
Compare
Function prototypes changed to use array parameters instead of pointers. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
In GCC 11, parameters declared as arrays in function prototypes cannot be declared as pointers in the function definition. The same is true for the other way around. The definition of `mbedtls_aes_cmac_prf_128` was changed to match its public prototype in `cmac.h`. The type `output` was `unsigned char *`, now is `unsigned char [16]`. In `ssl_tls.c`, all the `ssl_calc_verify_*` variants now use pointers for the output `hash` parameter. The array parameters were removed because those functions must be compatible with the function pointer `calc_verify` (defined in `ssl_internal.h`). Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
GCC 11 generated the warnings because the parameter `ret_buf` was declared as `const char[10]`, but some of the arguments provided in `run_test_snprintf` are shorter literals, like "". Now the type of `ret_buf` is `const char *`. Both implementations of `test_snprintf` were fixed. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
GCC 11 generated a warning because `padbuf` was too small to be used as an argument for `mbedtls_sha512_finish_ret`. The `output` parameter of `mbedtls_sha512_finish_ret` has the type `unsigned char[64]`, but `padbuf` was only 48 bytes long. Even though `ssl_calc_finished_tls_sha384` uses only 48 bytes for the hash output, the size of `padbuf` was increased to 64 bytes. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
This commit fixes the same warning fixed by baeedbf, but without wasting RAM. By casting `mbedtls_sha512_finish_ret()`, `padbuf` could be kept 48 bytes long without triggering any warnings. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
72783c5
to
d596ca8
Compare
`finish_sha384_t` was made more generic by using `unsigned char*` instead of `unsigned char[48]` as the second parameter. This change tries to make the function casting more robust against future improvements of gcc analysis. Signed-off-by: Rodrigo Dias Correa <rodrigo@correas.us>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This needs to be backported to 2.16 and 2.7 (where applicable). Please wait for a second approval on this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. As already mentioned, this just needs backports and then we can merge.
Function prototypes changed to use array parameters instead of
pointers.
Signed-off-by: Rodrigo Dias Corrêa rodrigo@correas.us
Description
Fixes #3782
Status
READY
Requires Backporting
I don't know.
Migrations
NO