added s3 max segment length check
This commit is contained in:
		| @@ -48,6 +48,7 @@ inline constexpr auto default_timeout_ms{60000U}; | ||||
| inline constexpr auto default_ui_mgmt_port{std::uint16_t{30000U}}; | ||||
| inline constexpr auto max_ring_buffer_file_size{std::uint16_t(1024U)}; | ||||
| inline constexpr auto max_s3_object_name_length{1024U}; | ||||
| inline constexpr auto max_s3_segment_name_length{255U}; | ||||
| inline constexpr auto min_cache_size_bytes{ | ||||
|     std::uint64_t(100ULL * 1024ULL * 1024ULL), | ||||
| }; | ||||
|   | ||||
| @@ -48,6 +48,16 @@ namespace { | ||||
| [[nodiscard]] auto set_request_path(auto &request, std::string_view object_name) | ||||
|     -> repertory::api_error { | ||||
|   request.path = object_name; | ||||
|  | ||||
|   { | ||||
|     auto parts = repertory::utils::string::split(request.path, '/', false); | ||||
|     if (std::ranges::find_if(parts, [](auto &&part) -> bool { | ||||
|           return part.size() > repertory::max_s3_segment_name_length; | ||||
|         }) != parts.end()) { | ||||
|       return repertory::api_error::name_too_long; | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   return (request.path.substr(1U).size() > repertory::max_s3_object_name_length) | ||||
|              ? repertory::api_error::name_too_long | ||||
|              : repertory::api_error::success; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user