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:
parent
be59e07881
commit
6d259ac4b7
|
@ -43,6 +43,7 @@ std::vector<char> readFile(const std::string &fileName, size_t &retSize) {
|
||||||
|
|
||||||
IoFunctions::fseekPtr(fileDescriptor, 0, SEEK_END);
|
IoFunctions::fseekPtr(fileDescriptor, 0, SEEK_END);
|
||||||
size = IoFunctions::ftellPtr(fileDescriptor);
|
size = IoFunctions::ftellPtr(fileDescriptor);
|
||||||
|
UNRECOVERABLE_IF(size == -1);
|
||||||
IoFunctions::rewindPtr(fileDescriptor);
|
IoFunctions::rewindPtr(fileDescriptor);
|
||||||
|
|
||||||
retBuf.resize(size);
|
retBuf.resize(size);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Intel Corporation
|
* Copyright (C) 2022-2023 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -27,6 +27,7 @@ std::unique_ptr<char[]> loadDataFromFile(
|
||||||
// Allocate a buffer for the file contents
|
// Allocate a buffer for the file contents
|
||||||
fseek(fp, 0, SEEK_END);
|
fseek(fp, 0, SEEK_END);
|
||||||
nsize = static_cast<size_t>(ftell(fp));
|
nsize = static_cast<size_t>(ftell(fp));
|
||||||
|
UNRECOVERABLE_IF(nsize == static_cast<size_t>(-1));
|
||||||
|
|
||||||
fseek(fp, 0, SEEK_SET);
|
fseek(fp, 0, SEEK_SET);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue