mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-30 22:43:08 +03:00
Fix gcc -O3 warnings
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
@ -224,6 +224,10 @@ int mbedtls_cipher_cmac_update(mbedtls_cipher_context_t *ctx,
|
|||||||
block_size = mbedtls_cipher_info_get_block_size(ctx->cipher_info);
|
block_size = mbedtls_cipher_info_get_block_size(ctx->cipher_info);
|
||||||
state = ctx->cmac_ctx->state;
|
state = ctx->cmac_ctx->state;
|
||||||
|
|
||||||
|
/* Without the MBEDTLS_ASSUME below, gcc -O3 will generate a warning of the form
|
||||||
|
* error: writing 16 bytes into a region of size 0 [-Werror=stringop-overflow=] */
|
||||||
|
MBEDTLS_ASSUME(block_size <= MBEDTLS_CMAC_MAX_BLOCK_SIZE);
|
||||||
|
|
||||||
/* Is there data still to process from the last call, that's greater in
|
/* Is there data still to process from the last call, that's greater in
|
||||||
* size than a block? */
|
* size than a block? */
|
||||||
if (cmac_ctx->unprocessed_len > 0 &&
|
if (cmac_ctx->unprocessed_len > 0 &&
|
||||||
@ -291,6 +295,7 @@ int mbedtls_cipher_cmac_finish(mbedtls_cipher_context_t *ctx,
|
|||||||
|
|
||||||
cmac_ctx = ctx->cmac_ctx;
|
cmac_ctx = ctx->cmac_ctx;
|
||||||
block_size = mbedtls_cipher_info_get_block_size(ctx->cipher_info);
|
block_size = mbedtls_cipher_info_get_block_size(ctx->cipher_info);
|
||||||
|
MBEDTLS_ASSUME(block_size <= MBEDTLS_CMAC_MAX_BLOCK_SIZE); // silence GCC warning
|
||||||
state = cmac_ctx->state;
|
state = cmac_ctx->state;
|
||||||
|
|
||||||
mbedtls_platform_zeroize(K1, sizeof(K1));
|
mbedtls_platform_zeroize(K1, sizeof(K1));
|
||||||
|
@ -412,8 +412,17 @@ int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,
|
|||||||
while (iv_len > 0) {
|
while (iv_len > 0) {
|
||||||
use_len = (iv_len < 16) ? iv_len : 16;
|
use_len = (iv_len < 16) ? iv_len : 16;
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_COMPILER_IS_GCC)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic warning "-Wstringop-overflow=0"
|
||||||
|
#endif
|
||||||
|
|
||||||
mbedtls_xor(ctx->y, ctx->y, p, use_len);
|
mbedtls_xor(ctx->y, ctx->y, p, use_len);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_COMPILER_IS_GCC)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
gcm_mult(ctx, ctx->y, ctx->y);
|
gcm_mult(ctx, ctx->y, ctx->y);
|
||||||
|
|
||||||
iv_len -= use_len;
|
iv_len -= use_len;
|
||||||
|
Reference in New Issue
Block a user