From fc0b6bbecb19ab4b0b06dcbf27b0ccc225ed142a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 29 Jan 2023 15:34:33 -0800 Subject: [PATCH] ircd::fs: Assertions for file read length sanity. --- ircd/db_env.cc | 2 ++ ircd/fs.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/ircd/db_env.cc b/ircd/db_env.cc index d9ac66300..39cafd1de 100644 --- a/ircd/db_env.cc +++ b/ircd/db_env.cc @@ -3421,6 +3421,7 @@ const noexcept try fs::read(fd, buf, opts) }; + assert(!opts.all || size(read) == length); *result = slice(read); return Status::OK(); } @@ -3862,6 +3863,7 @@ const noexcept try fs::read(fd, buf, opts) }; + assert(!opts.all || size(read) == length); *result = slice(read); return Status::OK(); } diff --git a/ircd/fs.cc b/ircd/fs.cc index 714733c3e..74210d7e7 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -1089,6 +1089,7 @@ ircd::fs::_read_asio(const fd &fd, } }; + assert(ret <= bytes(iov)); assert(ret || ec == eof); if(unlikely(ec && ec != eof)) throw_system_error(ec);