Skip to content

Commit 1d0091c

Browse files
authored
Adapt to aws_base64_compute_encoded_len() no longer adding 1 extra for null terminator (#497)
1 parent 9baaa31 commit 1d0091c

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

source/s3_chunk_stream.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ struct aws_input_stream *aws_chunk_stream_new(
259259
if (aws_input_stream_get_length(impl->current_stream, &prechunk_stream_len)) {
260260
goto error;
261261
}
262-
/* we subtract one since aws_base64_compute_encoded_len accounts for the null terminator which won't show up in our
263-
* stream */
262+
264263
impl->length = prechunk_stream_len + stream_length + final_chunk_len + impl->checksum_header_name.len + colon_len +
265-
encoded_checksum_len + post_trailer_len - 1;
264+
encoded_checksum_len + post_trailer_len;
266265

267266
AWS_ASSERT(impl->current_stream);
268267
aws_ref_count_init(&impl->base.ref_count, impl, (aws_simple_completion_callback *)s_aws_input_chunk_stream_destroy);

source/s3_meta_request.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ static void s_get_part_response_headers_checksum_helper(
12461246
if (s_header_value_from_list(headers, headers_count, algorithm_header_name, &header_sum)) {
12471247
size_t encoded_len = 0;
12481248
aws_base64_compute_encoded_len(aws_get_digest_size_from_checksum_algorithm(algorithm), &encoded_len);
1249-
if (header_sum.len == encoded_len - 1) {
1249+
if (header_sum.len == encoded_len) {
12501250
aws_byte_buf_init_copy_from_cursor(
12511251
&connection->request->request_level_response_header_checksum, meta_request->allocator, header_sum);
12521252
connection->request->request_level_running_response_sum =

source/s3_util.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ int aws_s3_check_headers_for_checksum(
746746
/* Found the checksum header, keep the header value and initialize the running checksum */
747747
size_t encoded_len = 0;
748748
aws_base64_compute_encoded_len(aws_get_digest_size_from_checksum_algorithm(algorithm), &encoded_len);
749-
if (checksum_value.len == encoded_len - 1) {
750-
/* encoded_len includes the nullptr length. -1 is the expected length. */
749+
if (checksum_value.len == encoded_len) {
751750
aws_byte_buf_init_copy_from_cursor(out_checksum_buffer, meta_request->allocator, checksum_value);
752751
*out_checksum = aws_checksum_new(meta_request->allocator, algorithm);
753752
if (!*out_checksum) {

0 commit comments

Comments
 (0)