]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/tools/store-nbd: actually check magic 39588/head
authorSamuel Just <sjust@redhat.com>
Sat, 20 Feb 2021 03:17:48 +0000 (03:17 +0000)
committerSamuel Just <sjust@redhat.com>
Sat, 20 Feb 2021 03:28:21 +0000 (03:28 +0000)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/tools/store-nbd.cc

index ddaae6e65068ebc84a59f873c52c5a3180c747a6..fc0975b153f66d467176447c8c03eee0e93855eb 100644 (file)
@@ -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);