Skip to content

Commit b84d7e3

Browse files
committed
rgw/admin: Fix assert on datalog list of invalid shard
Fixes: https://tracker.ceph.com/issues/70882 Signed-off-by: Adam C. Emerson <[email protected]>
1 parent a674144 commit b84d7e3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/rgw/driver/rados/rgw_datalog.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <boost/container/flat_map.hpp>
1717

1818
#include <boost/system/system_error.hpp>
19+
#include <boost/system/generic_category.hpp>
1920

2021
#include "include/fs_types.h"
2122
#include "include/neorados/RADOS.hpp"
@@ -1091,7 +1092,12 @@ asio::awaitable<std::tuple<std::vector<rgw_data_change_log_entry>,
10911092
RGWDataChangesLog::list_entries(const DoutPrefixProvider* dpp, int shard,
10921093
int max_entries, std::string marker)
10931094
{
1094-
assert(shard < num_shards);
1095+
if (shard >= num_shards) [[unlikely]] {
1096+
throw sys::system_error{
1097+
EINVAL, sys::generic_category(),
1098+
fmt::format("{} is not a valid shard. Valid shards are integers in [0, {})",
1099+
shard, num_shards)};
1100+
}
10951101
if (max_entries <= 0) {
10961102
co_return std::make_tuple(std::vector<rgw_data_change_log_entry>{},
10971103
std::string{});
@@ -1109,7 +1115,6 @@ int RGWDataChangesLog::list_entries(
11091115
std::string_view marker, std::string* out_marker, bool* truncated,
11101116
optional_yield y)
11111117
{
1112-
assert(shard < num_shards);
11131118
std::exception_ptr eptr;
11141119
std::tuple<std::span<rgw_data_change_log_entry>,
11151120
std::string> out;

0 commit comments

Comments
 (0)