1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-17 13:25:45 +02:00

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 <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2020-11-04 21:13:11 -05:00
parent f45e379802
commit 9ca69bb7ff

View File

@ -205,10 +205,10 @@ namespace crucible {
get_struct_ptr(const V &v, size_t offset = 0) get_struct_ptr(const V &v, size_t offset = 0)
{ {
// OK so sometimes btrfs overshoots a little // OK so sometimes btrfs overshoots a little
if (offset + sizeof(T) > v.size()) { // if (offset + sizeof(T) > v.size()) {
v.resize(offset + sizeof(T), 0); // v.resize(offset + sizeof(T), 0);
} // }
THROW_CHECK2(invalid_argument, v.size(), offset + sizeof(T), offset + sizeof(T) <= v.size()); // THROW_CHECK2(invalid_argument, v.size(), offset + sizeof(T), offset + sizeof(T) <= v.size());
return reinterpret_cast<const T*>(v.data() + offset); return reinterpret_cast<const T*>(v.data() + offset);
} }