diff --git a/src/common/utils/byte_buffer.cpp b/src/common/utils/byte_buffer.cpp index c471858a..2ef0a3b0 100644 --- a/src/common/utils/byte_buffer.cpp +++ b/src/common/utils/byte_buffer.cpp @@ -1,7 +1,6 @@ #include "byte_buffer.hpp" #include -#include namespace utils { diff --git a/src/common/utils/byte_buffer.hpp b/src/common/utils/byte_buffer.hpp index 662a5919..6a801968 100644 --- a/src/common/utils/byte_buffer.hpp +++ b/src/common/utils/byte_buffer.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace utils { @@ -73,8 +74,13 @@ namespace utils std::vector read_vector() { std::vector result{}; - result.resize(read()); - read(result.data(), result.size() * sizeof(T)); + const auto size = read(); + if (offset_ + size > buffer_.size()) + { + throw std::runtime_error("Out of bounds read from byte buffer"); + } + + read(result.data(), size); return result; }