From 53b6408ebf5dbf2998cd99876d99bceea8897095 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 (cherry picked from commit b84d7e3530730d0f94736fa12848125925d1a4f0) 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 6cf00adc73e91..3594d44e6f370 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 "common/async/parallel_for_each.h" #include "include/fs_types.h" @@ -1092,7 +1093,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{}); @@ -1110,7 +1116,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