From a33462f806b729968dc6fdf8acfc169da3af5523 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 11 Oct 2016 17:34:05 +0200 Subject: rgw: protect the {ACCOUNTING,AWS_AUTHv4,RESTFUL}_IO casts with assert. Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_client_io.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/rgw/rgw_client_io.h') diff --git a/src/rgw/rgw_client_io.h b/src/rgw/rgw_client_io.h index 5db0a9f45bf..82460d0d102 100644 --- a/src/rgw/rgw_client_io.h +++ b/src/rgw/rgw_client_io.h @@ -213,14 +213,21 @@ public: /* Type conversions to work around lack of req_state type hierarchy matching * (e.g.) REST backends (may be replaced w/dynamic typed req_state). */ static inline rgw::io::RestfulClient* RESTFUL_IO(struct req_state* s) { + assert(dynamic_cast(s->cio) != nullptr); + return static_cast(s->cio); } static inline rgw::io::Accounter* ACCOUNTING_IO(struct req_state* s) { - return dynamic_cast(s->cio); + auto ptr = dynamic_cast(s->cio); + assert(ptr != nullptr); + + return ptr; } static inline RGWRestfulIO* AWS_AUTHv4_IO(struct req_state* s) { + assert(dynamic_cast(s->cio) != nullptr); + return static_cast(s->cio); } -- cgit v1.2.3