From 9ca69bb7ff6649cb5722d61406ae11ffb9d193e7 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Wed, 4 Nov 2020 21:13:11 -0500 Subject: [PATCH] fs: remove buffer overrun check in get_struct_ptr for non-copying containers When we are using non-copying containers, we can't call resize() on them. get_struct_ptr is essentially a pointer cast, so we will end up with a pointer to a struct that extends beyond the boundaries of the container. As long as the btrfs metadata is not corrupted, we should not have too many problems. Signed-off-by: Zygo Blaxell --- include/crucible/fs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/crucible/fs.h b/include/crucible/fs.h index 25e3eda..a9c8960 100644 --- a/include/crucible/fs.h +++ b/include/crucible/fs.h @@ -205,10 +205,10 @@ namespace crucible { get_struct_ptr(const V &v, size_t offset = 0) { // OK so sometimes btrfs overshoots a little - if (offset + sizeof(T) > v.size()) { - v.resize(offset + sizeof(T), 0); - } - THROW_CHECK2(invalid_argument, v.size(), offset + sizeof(T), offset + sizeof(T) <= v.size()); + // if (offset + sizeof(T) > v.size()) { + // v.resize(offset + sizeof(T), 0); + // } + // THROW_CHECK2(invalid_argument, v.size(), offset + sizeof(T), offset + sizeof(T) <= v.size()); return reinterpret_cast(v.data() + offset); }