From 13f2710c37291c40e6149f7f1d31384d2c9f25a0 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 17 Jul 2014 17:10:36 -0400 Subject: [PATCH] Document that EVP_EncodeBlock writes a trailing NUL. Fix base64_test.c to account for this. Change-Id: I0b3e8062a2130fb01a7e6f175968484769c406f9 Reviewed-on: https://boringssl-review.googlesource.com/1250 Reviewed-by: Adam Langley --- crypto/base64/base64_test.c | 2 +- include/openssl/base64.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crypto/base64/base64_test.c b/crypto/base64/base64_test.c index 992f13b0..0cd2b6ec 100644 --- a/crypto/base64/base64_test.c +++ b/crypto/base64/base64_test.c @@ -38,7 +38,7 @@ static const TEST_VECTOR test_vectors[] = { static const size_t kNumTests = sizeof(test_vectors) / sizeof(test_vectors[0]); static int test_encode() { - uint8_t out[8]; + uint8_t out[9]; size_t i; ssize_t len; diff --git a/include/openssl/base64.h b/include/openssl/base64.h index c4d312c6..52dfd6d0 100644 --- a/include/openssl/base64.h +++ b/include/openssl/base64.h @@ -94,8 +94,9 @@ void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, uint8_t *out, int *out_len, * sets |*out_len| to the number of bytes written. */ void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, uint8_t *out, int *out_len); -/* EVP_EncodeBlock encodes |src_len| bytes from |src| and writes the result to - * |dst|. It returns the number of bytes written. */ +/* EVP_EncodeBlock encodes |src_len| bytes from |src| and writes the + * result to |dst| with a trailing NUL. It returns the number of bytes + * written, not including this trailing NUL. */ size_t EVP_EncodeBlock(uint8_t *dst, const uint8_t *src, size_t src_len);