From a232a75b3b87a37d2df89786ee978925770d07d9 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Sat, 20 Feb 2021 03:27:49 +0000 Subject: [PATCH] crimson/tools/store-nbd: check length of buffer read_exactly does not return an error if the stream has ended. Signed-off-by: Samuel Just --- src/crimson/tools/store-nbd.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crimson/tools/store-nbd.cc b/src/crimson/tools/store-nbd.cc index 839daff8dc6..ddaae6e6506 100644 --- a/src/crimson/tools/store-nbd.cc +++ b/src/crimson/tools/store-nbd.cc @@ -168,6 +168,11 @@ struct request_context_t { seastar::future<> read_request(seastar::input_stream &in) { return in.read_exactly(sizeof(struct nbd_request) ).then([this, &in](auto buf) { + if (buf.size() < sizeof(struct nbd_request)) { + throw std::system_error( + std::make_error_code( + std::errc::connection_reset)); + } auto p = buf.get(); magic = seastar::consume_be(p); type = seastar::consume_be(p); -- 2.39.5