From f1befa25d7f8551338e37b2133d6016aed5c4432 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 23 Feb 2024 09:02:29 -0500 Subject: [PATCH] rgw/auth: do_aws4_auth_completion() catches exceptions AWSv4ComplMulti::complete() throws exceptions on errors, but nothing catches these Fixes: https://tracker.ceph.com/issues/64549 Signed-off-by: Casey Bodley (cherry picked from commit f953c419d6992c8124f3e123ae8030d6a45ffd1a) --- src/rgw/rgw_op.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f6011dbe5c9..721c0e17936 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1407,16 +1407,20 @@ int RGWOp::do_aws4_auth_completion() { ldpp_dout(this, 5) << "NOTICE: call to do_aws4_auth_completion" << dendl; if (s->auth.completer) { - if (!s->auth.completer->complete()) { - return -ERR_AMZ_CONTENT_SHA256_MISMATCH; - } else { - ldpp_dout(this, 10) << "v4 auth ok -- do_aws4_auth_completion" << dendl; - } - /* TODO(rzarzynski): yes, we're really called twice on PUTs. Only first * call passes, so we disable second one. This is old behaviour, sorry! * Plan for tomorrow: seek and destroy. */ - s->auth.completer = nullptr; + auto completer = std::move(s->auth.completer); + + try { + if (!completer->complete()) { + return -ERR_AMZ_CONTENT_SHA256_MISMATCH; + } + } catch (const rgw::io::Exception& e) { + return -e.code().value(); + } + + ldpp_dout(this, 10) << "v4 auth ok -- do_aws4_auth_completion" << dendl; } return 0; -- 2.39.5