diff --git a/src/libsodium/sodium/codecs.c b/src/libsodium/sodium/codecs.c index 7e203a5c..247c9c0d 100644 --- a/src/libsodium/sodium/codecs.c +++ b/src/libsodium/sodium/codecs.c @@ -215,7 +215,9 @@ sodium_bin2base64(char * const b64, const size_t b64_maxlen, while (b64_pos < b64_len) { b64[b64_pos++] = '='; } - b64[b64_pos++] = 0; + do { + b64[b64_pos++] = 0U; + } while (b64_pos < b64_maxlen); return b64; } diff --git a/test/default/sodium_utils.c b/test/default/sodium_utils.c index d748f1ef..0da2ec34 100644 --- a/test/default/sodium_utils.c +++ b/test/default/sodium_utils.c @@ -161,7 +161,7 @@ main(void) b64_ = (char *) sodium_malloc(b64_len); randombytes_buf(bin, bin_len); memcpy(buf1, bin, bin_len); - b64 = sodium_bin2base64(b64_, b64_len + 10, bin, bin_len, + b64 = sodium_bin2base64(b64_, b64_len, bin, bin_len, sodium_base64_VARIANT_URLSAFE); assert(b64 != NULL); assert(sodium_base642bin(bin, bin_len + 10, b64, b64_len,