Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Coverity Enterprise][Core][Samples]Denial of service, unreliable execution (#30629)

barnasm100f3ecc3f148
diff --git a/src/core/src/runtime/tensor.cpp b/src/core/src/runtime/tensor.cpp
index d826c690846..ac57e412417 100644
--- a/src/core/src/runtime/tensor.cpp
+++ b/src/core/src/runtime/tensor.cpp
@@ -178,6 +178,14 @@ void read_tensor_data(const std::filesystem::path& file_name, Tensor& tensor, si
std::ifstream fin(file_name, std::ios::binary);
fin.seekg(offset);
auto bytes_to_read = tensor.get_byte_size();
+
+ OPENVINO_ASSERT(bytes_to_read <= static_cast<size_t>(std::numeric_limits<std::streamsize>::max()),
+ "Cannot read ",
+ bytes_to_read,
+ " bytes from ",
+ file_name,
+ ", because the value exceeds std::streamsize limit");
+
fin.read(static_cast<char*>(tensor.data()), bytes_to_read);
OPENVINO_ASSERT(static_cast<size_t>(fin.gcount()) == bytes_to_read,
"Cannot read ",