Skip to content

Commit

Permalink
Merge pull request #56884 from ClickHouse/cherrypick/23.8/147a04b5ebc…
Browse files Browse the repository at this point in the history
…d3fd649c0da1e5ba21d65e330ef24

Cherry pick #56854 to 23.8: Better exception messages
  • Loading branch information
robot-ch-test-poll1 committed Nov 16, 2023
2 parents aa8becd + 147a04b commit d5226d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Compression/CompressionCodecFPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,15 @@ class FPCOperation
std::to_integer<UInt32>(bytes.front()) & MAX_ZERO_BYTE_COUNT);

if (zero_byte_count1 > VALUE_SIZE || zero_byte_count2 > VALUE_SIZE) [[unlikely]]
throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Invalid compressed data");
throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Invalid zero byte count(s): {} and {}", zero_byte_count1, zero_byte_count2);

size_t tail_size1 = VALUE_SIZE - zero_byte_count1;
size_t tail_size2 = VALUE_SIZE - zero_byte_count2;

size_t expected_size = 0;
if (__builtin_add_overflow(tail_size1, tail_size2, &expected_size)
|| __builtin_add_overflow(expected_size, 1, &expected_size)) [[unlikely]]
throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Invalid compressed data");
throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Overflow occurred while calculating expected size");

if (bytes.size() < expected_size) [[unlikely]]
throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Unexpected end of encoded sequence");
Expand Down

0 comments on commit d5226d4

Please sign in to comment.