Explain some aspects of the tests
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/tests/suites/test_suite_base64.data b/tests/suites/test_suite_base64.data
index 547b9fd..feed172 100644
--- a/tests/suites/test_suite_base64.data
+++ b/tests/suites/test_suite_base64.data
@@ -78,6 +78,8 @@
# 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 @@
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
diff --git a/tests/suites/test_suite_base64.function b/tests/suites/test_suite_base64.function
index 8c948b4..df63aea 100644
--- a/tests/suites/test_suite_base64.function
+++ b/tests/suites/test_suite_base64.function
@@ -92,11 +92,16 @@
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 */