From b84d7e3530730d0f94736fa12848125925d1a4f0 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Fri, 11 Apr 2025 17:53:58 -0400 Subject: [PATCH] rgw/admin: Fix assert on datalog list of invalid shard Fixes: https://tracker.ceph.com/issues/70882 Signed-off-by: Adam C. Emerson --- src/rgw/driver/rados/rgw_datalog.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index f30fffd320f..9f5cacb763e 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -16,6 +16,7 @@ #include #include +#include #include "include/fs_types.h" #include "include/neorados/RADOS.hpp" @@ -1091,7 +1092,12 @@ asio::awaitable, RGWDataChangesLog::list_entries(const DoutPrefixProvider* dpp, int shard, int max_entries, std::string marker) { - assert(shard < num_shards); + if (shard >= num_shards) [[unlikely]] { + throw sys::system_error{ + EINVAL, sys::generic_category(), + fmt::format("{} is not a valid shard. Valid shards are integers in [0, {})", + shard, num_shards)}; + } if (max_entries <= 0) { co_return std::make_tuple(std::vector{}, std::string{}); @@ -1109,7 +1115,6 @@ int RGWDataChangesLog::list_entries( std::string_view marker, std::string* out_marker, bool* truncated, optional_yield y) { - assert(shard < num_shards); std::exception_ptr eptr; std::tuple, std::string> out; -- 2.39.5