From 40e30defb38dfb3d10e5d69675c3870b1791b103 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Sat, 30 Aug 2025 16:54:26 -0500 Subject: [PATCH] added s3 max segment length check --- repertory/librepertory/include/types/repertory.hpp | 1 + .../librepertory/src/providers/s3/s3_provider.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 20d0153f..a09472dd 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -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), }; diff --git a/repertory/librepertory/src/providers/s3/s3_provider.cpp b/repertory/librepertory/src/providers/s3/s3_provider.cpp index fa5e27e9..666a51dc 100644 --- a/repertory/librepertory/src/providers/s3/s3_provider.cpp +++ b/repertory/librepertory/src/providers/s3/s3_provider.cpp @@ -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;