mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-03-20 19:21:09 +01:00
Explain some aspects of the tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
@@ -78,6 +78,8 @@ mbedtls_base64_decode:"zm masd":"":MBEDTLS_ERR_BASE64_INVALID_CHARACTER
|
||||
|
||||
# The next few test cases validate systematically for short inputs that
|
||||
# we require the correct number of trailing equal signs.
|
||||
|
||||
# 4k+1 digits is always wrong (wouldn't encode more bytes than 4k digits)
|
||||
Base64 decode: 1 digit, 0 equals (bad)
|
||||
mbedtls_base64_decode:"Y":"":MBEDTLS_ERR_BASE64_INVALID_CHARACTER
|
||||
|
||||
@@ -126,6 +128,7 @@ mbedtls_base64_decode:"Y29t==":"com":MBEDTLS_ERR_BASE64_INVALID_CHARACTER
|
||||
Base64 decode: 4 digits, 3 equals (bad)
|
||||
mbedtls_base64_decode:"Y29t===":"com":MBEDTLS_ERR_BASE64_INVALID_CHARACTER
|
||||
|
||||
# 4k+1 digits is always wrong (wouldn't encode more bytes than 4k digits)
|
||||
Base64 decode: 5 digits, 0 equals (bad)
|
||||
mbedtls_base64_decode:"Y29tc":"":MBEDTLS_ERR_BASE64_INVALID_CHARACTER
|
||||
|
||||
|
||||
@@ -92,11 +92,16 @@ void mbedtls_base64_decode(char *src_string, char *dst_string, int result)
|
||||
size_t dst_size = correct_dst_len;
|
||||
size_t len;
|
||||
|
||||
/* Allocate exactly the size of the input, to ensure there's no buffer
|
||||
* overread in builds with ASan. (src_string has at least one extra null
|
||||
* character at the end.) */
|
||||
TEST_CALLOC(src, src_len);
|
||||
if (src_len != 0) {
|
||||
memcpy(src, src_string, src_len);
|
||||
}
|
||||
|
||||
/* Allocate exactly the size of the input, to ensure there's no buffer
|
||||
* overflow in builds with ASan. */
|
||||
TEST_CALLOC(dst, dst_size);
|
||||
|
||||
/* Test normal operation */
|
||||
|
||||
Reference in New Issue
Block a user