Merge pull request #47540 from Avogar/fix-bson-bug

Fix BSONEachRow parallel parsing when document size is invalid
This commit is contained in:
Kruglov Pavel 2023-03-16 16:25:25 +01:00 committed by GitHub
commit ffa8af2861
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 0 deletions

View File

@ -999,6 +999,9 @@ fileSegmentationEngineBSONEachRow(ReadBuffer & in, DB::Memory<> & memory, size_t
"the value setting 'min_chunk_bytes_for_parallel_parsing' or check your data manually, most likely BSON is malformed", "the value setting 'min_chunk_bytes_for_parallel_parsing' or check your data manually, most likely BSON is malformed",
min_bytes, document_size); min_bytes, document_size);
if (document_size < sizeof(document_size))
throw ParsingException(ErrorCodes::INCORRECT_DATA, "Size of BSON document is invalid");
size_t old_size = memory.size(); size_t old_size = memory.size();
memory.resize(old_size + document_size); memory.resize(old_size + document_size);
memcpy(memory.data() + old_size, reinterpret_cast<char *>(&document_size), sizeof(document_size)); memcpy(memory.data() + old_size, reinterpret_cast<char *>(&document_size), sizeof(document_size));

View File

@ -0,0 +1,2 @@
set input_format_parallel_parsing=1;
select * from format(BSONEachRow, 'x UInt32', x'00000000'); -- {serverError INCORRECT_DATA}