From 6d259ac4b7d53b48f6dbf24f3e28e6974b003528 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Wed, 4 Oct 2023 15:48:07 +0000 Subject: [PATCH] fix: add unrecoverable to avoid out of bound access Related-To: NEO-9038 Signed-off-by: Mateusz Jablonski --- shared/source/built_ins/sip.cpp | 1 + shared/source/helpers/file_io_load.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/shared/source/built_ins/sip.cpp b/shared/source/built_ins/sip.cpp index a901c6b6d6..7f3974ac25 100644 --- a/shared/source/built_ins/sip.cpp +++ b/shared/source/built_ins/sip.cpp @@ -43,6 +43,7 @@ std::vector readFile(const std::string &fileName, size_t &retSize) { IoFunctions::fseekPtr(fileDescriptor, 0, SEEK_END); size = IoFunctions::ftellPtr(fileDescriptor); + UNRECOVERABLE_IF(size == -1); IoFunctions::rewindPtr(fileDescriptor); retBuf.resize(size); diff --git a/shared/source/helpers/file_io_load.cpp b/shared/source/helpers/file_io_load.cpp index a166638490..1e23fd0847 100644 --- a/shared/source/helpers/file_io_load.cpp +++ b/shared/source/helpers/file_io_load.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -27,6 +27,7 @@ std::unique_ptr loadDataFromFile( // Allocate a buffer for the file contents fseek(fp, 0, SEEK_END); nsize = static_cast(ftell(fp)); + UNRECOVERABLE_IF(nsize == static_cast(-1)); fseek(fp, 0, SEEK_SET);