Skip to content

Commit

Permalink
Merge pull request #56887 from ClickHouse/backport/23.9/56854
Browse files Browse the repository at this point in the history
Backport #56854 to 23.9: Better exception messages
  • Loading branch information
alexey-milovidov committed Nov 16, 2023
2 parents a10814f + 838a2b3 commit 5a3fd4c
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 5a3fd4c

Please sign in to comment.