From: Samuel Just Date: Sat, 20 Feb 2021 03:17:48 +0000 (+0000) Subject: crimson/tools/store-nbd: actually check magic X-Git-Tag: v17.1.0~2914^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39588%2Fhead;p=ceph.git crimson/tools/store-nbd: actually check magic Signed-off-by: Samuel Just --- diff --git a/src/crimson/tools/store-nbd.cc b/src/crimson/tools/store-nbd.cc index ddaae6e65068..fc0975b153f6 100644 --- a/src/crimson/tools/store-nbd.cc +++ b/src/crimson/tools/store-nbd.cc @@ -153,8 +153,14 @@ struct request_context_t { } bool check_magic() const { - // todo - return true; + auto ret = magic == NBD_REQUEST_MAGIC; + if (!ret) { + logger().error( + "Invalid magic {} should be {}", + magic, + NBD_REQUEST_MAGIC); + } + return ret; } uint32_t get_command() const { @@ -184,6 +190,12 @@ struct request_context_t { "Got request, magic {}, type {}, from {}, len {}", magic, type, from, len); + if (!check_magic()) { + throw std::system_error( + std::make_error_code( + std::errc::invalid_argument)); + } + if (has_input_buffer()) { return in.read_exactly(len).then([this](auto buf) { in_buffer = ceph::buffer::create_page_aligned(len);