| 106 | |
| 107 | template <typename T> |
| 108 | std::enable_if_t<std::is_arithmetic_v<T>, std::string> FormatNumericValue( |
| 109 | ::std::string_view val) { |
| 110 | std::stringstream result; |
| 111 | // The statistics value comes from the file's Thrift metadata, so its length |
| 112 | // is attacker controlled and the spec allows it to be truncated. Only copy |
| 113 | // the bytes that are actually present and leave the rest zero-padded. |
| 114 | T value{}; |
| 115 | std::memcpy(&value, val.data(), std::min(sizeof(T), val.size())); |
| 116 | result << value; |
| 117 | return result.str(); |
| 118 | } |
| 119 | |
| 120 | std::string FormatDecimalValue(Type::type parquet_type, ::std::string_view val, |
| 121 | const std::shared_ptr<const LogicalType>& logical_type) { |