Reviewer comments

pull/22929/head
Yash Tibrewal 5 years ago
parent 17b6be1ed8
commit 8f11aba818
  1. 20
      test/core/compression/message_compress_test.cc

@ -198,27 +198,29 @@ static void test_bad_decompression_data_crc(void) {
static void test_bad_decompression_data_missing_trailer(void) { static void test_bad_decompression_data_missing_trailer(void) {
grpc_slice_buffer input; grpc_slice_buffer input;
grpc_slice_buffer corrupted; grpc_slice_buffer decompressed;
grpc_slice_buffer garbage;
grpc_slice_buffer output; grpc_slice_buffer output;
size_t idx;
grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&input);
grpc_slice_buffer_init(&corrupted); grpc_slice_buffer_init(&decompressed);
grpc_slice_buffer_init(&garbage);
grpc_slice_buffer_init(&output); grpc_slice_buffer_init(&output);
grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A)); grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A));
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
/* compress it */ /* compress it */
grpc_msg_compress(GRPC_MESSAGE_COMPRESS_GZIP, &input, &corrupted); grpc_msg_compress(GRPC_MESSAGE_COMPRESS_GZIP, &input, &decompressed);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[corrupted.count - 1]) > 8); GPR_ASSERT(decompressed.length > 8);
/* Remove the footer by manipulating the slice length */ /* Remove the footer from the decompressed message */
corrupted.slices[1].data.refcounted.length -= 8; grpc_slice_buffer_trim_end(&decompressed, 8, &garbage);
/* try (and fail) to decompress the compressed buffer without the footer */ /* try (and fail) to decompress the compressed buffer without the footer */
GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &corrupted, GPR_ASSERT(0 == grpc_msg_decompress(GRPC_MESSAGE_COMPRESS_GZIP, &decompressed,
&output)); &output));
grpc_slice_buffer_destroy(&input); grpc_slice_buffer_destroy(&input);
grpc_slice_buffer_destroy(&corrupted); grpc_slice_buffer_destroy(&decompressed);
grpc_slice_buffer_destroy(&garbage);
grpc_slice_buffer_destroy(&output); grpc_slice_buffer_destroy(&output);
} }

Loading…
Cancel
Save