Clean up of formatting, and potential integer overflow fix
diff --git a/library/cmac.c b/library/cmac.c
index 9e4dc89..03d9392 100644
--- a/library/cmac.c
+++ b/library/cmac.c
@@ -245,7 +245,7 @@
{
mbedtls_cmac_context_t* cmac_ctx;
unsigned char *state;
- int n, j, ret = 0;
+ int n, j, ret = 0;
size_t olen, block_size;
if( ctx == NULL || ctx->cipher_info == NULL || input == NULL ||
@@ -259,7 +259,7 @@
/* Is their data still to process from the last call, that's equal to
* or greater than a block? */
if( cmac_ctx->unprocessed_len > 0 &&
- ilen + cmac_ctx->unprocessed_len > block_size )
+ ilen > block_size - cmac_ctx->unprocessed_len )
{
memcpy( &cmac_ctx->unprocessed_block[cmac_ctx->unprocessed_len],
input,
@@ -387,7 +387,7 @@
/* Reset the internal state */
cmac_ctx->unprocessed_len = 0;
mbedtls_zeroize( cmac_ctx->unprocessed_block,
- sizeof( cmac_ctx->unprocessed_block ));
+ sizeof( cmac_ctx->unprocessed_block ) );
mbedtls_zeroize( cmac_ctx->state,
sizeof( cmac_ctx->state ) );
cmac_ctx->padding_flag = 1;
@@ -822,7 +822,7 @@
for( i = 0; i < num_tests; i++ )
{
if( verbose != 0 )
- mbedtls_printf( " %s CMAC #%u: ", testname, i +1 );
+ mbedtls_printf( " %s CMAC #%u: ", testname, i + 1 );
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages,
message_lengths[i], output ) ) != 0 )