From: Adam C. Emerson Date: Fri, 11 Apr 2025 21:53:58 +0000 (-0400) Subject: rgw/admin: Fix assert on datalog list of invalid shard X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b84d7e3530730d0f94736fa12848125925d1a4f0;p=ceph.git rgw/admin: Fix assert on datalog list of invalid shard Fixes: https://tracker.ceph.com/issues/70882 Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index f30fffd320fe..9f5cacb763eb 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;