mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-04-16 08:42:50 +00:00
Check length before calling memcmp
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
102033c38d
commit
a68ef95394
@ -106,7 +106,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the result of the operation against the sample */
|
/* Check the result of the operation against the sample */
|
||||||
if ((memcmp(hash, sample_hash, sample_hash_len) != 0) || hash_length != sample_hash_len) {
|
if (hash_length != sample_hash_len || (memcmp(hash, sample_hash, sample_hash_len) != 0)) {
|
||||||
mbedtls_printf("Multi-part hash operation gave the wrong result!\n\n");
|
mbedtls_printf("Multi-part hash operation gave the wrong result!\n\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ int main(void)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(hash, sample_hash, sample_hash_len) != 0 || hash_length != sample_hash_len) {
|
if (hash_length != sample_hash_len || (memcmp(hash, sample_hash, sample_hash_len) != 0)) {
|
||||||
mbedtls_printf("One-shot hash operation gave the wrong result!\n\n");
|
mbedtls_printf("One-shot hash operation gave the wrong result!\n\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user