| 493 | } // namespace |
| 494 | |
| 495 | Status FuzzEncoding(const uint8_t* data, int64_t size) { |
| 496 | constexpr auto kInt32Max = std::numeric_limits<int32_t>::max(); |
| 497 | |
| 498 | ARROW_ASSIGN_OR_RAISE(const auto parse_result, |
| 499 | FuzzEncodingHeader::Parse(std::span(data, size))); |
| 500 | const auto header = parse_result.first; |
| 501 | const auto encoded_data = parse_result.second; |
| 502 | if (encoded_data.size() > static_cast<size_t>(kInt32Max)) { |
| 503 | // Unlikely but who knows? |
| 504 | return Status::Invalid("Fuzz payload too large"); |
| 505 | } |
| 506 | const auto descr = MakeColumnDescriptor(header.type, header.type_length); |
| 507 | |
| 508 | BEGIN_PARQUET_CATCH_EXCEPTIONS |
| 509 | |
| 510 | auto typed_fuzz = [&](auto* dtype) { |
| 511 | using DType = std::decay_t<decltype(*dtype)>; |
| 512 | TypedFuzzEncoding<DType> typed_fuzz{header.source_encoding, header.roundtrip_encoding, |
| 513 | &descr, header.num_values, encoded_data}; |
| 514 | return typed_fuzz.Fuzz(); |
| 515 | }; |
| 516 | RETURN_NOT_OK(VisitType(header.type, typed_fuzz)); |
| 517 | |
| 518 | END_PARQUET_CATCH_EXCEPTIONS |
| 519 | return Status::OK(); |
| 520 | } |
| 521 | |
| 522 | } // namespace parquet::fuzzing::internal |
no test coverage detected