| 468 | } // namespace |
| 469 | |
| 470 | Status FuzzEncoding(const uint8_t* data, int64_t size) { |
| 471 | constexpr auto kInt32Max = std::numeric_limits<int32_t>::max(); |
| 472 | |
| 473 | ARROW_ASSIGN_OR_RAISE(const auto parse_result, |
| 474 | FuzzEncodingHeader::Parse(std::span(data, size))); |
| 475 | const auto header = parse_result.first; |
| 476 | const auto encoded_data = parse_result.second; |
| 477 | if (encoded_data.size() > static_cast<size_t>(kInt32Max)) { |
| 478 | // Unlikely but who knows? |
| 479 | return Status::Invalid("Fuzz payload too large"); |
| 480 | } |
| 481 | const auto descr = MakeColumnDescriptor(header.type, header.type_length); |
| 482 | |
| 483 | BEGIN_PARQUET_CATCH_EXCEPTIONS |
| 484 | |
| 485 | auto typed_fuzz = [&](auto* dtype) { |
| 486 | using DType = std::decay_t<decltype(*dtype)>; |
| 487 | TypedFuzzEncoding<DType> typed_fuzz{header.source_encoding, header.roundtrip_encoding, |
| 488 | &descr, header.num_values, encoded_data}; |
| 489 | return typed_fuzz.Fuzz(); |
| 490 | }; |
| 491 | RETURN_NOT_OK(VisitType(header.type, typed_fuzz)); |
| 492 | |
| 493 | END_PARQUET_CATCH_EXCEPTIONS |
| 494 | return Status::OK(); |
| 495 | } |
| 496 | |
| 497 | } // namespace parquet::fuzzing::internal |
no test coverage detected