fix: add unrecoverable to avoid out of bound access

Related-To: NEO-9038
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2023-10-04 15:48:07 +00:00 committed by Compute-Runtime-Automation
parent be59e07881
commit 6d259ac4b7
2 changed files with 3 additions and 1 deletions

View File

@ -43,6 +43,7 @@ std::vector<char> 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);

View File

@ -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<char[]> loadDataFromFile(
// Allocate a buffer for the file contents
fseek(fp, 0, SEEK_END);
nsize = static_cast<size_t>(ftell(fp));
UNRECOVERABLE_IF(nsize == static_cast<size_t>(-1));
fseek(fp, 0, SEEK_SET);