From 8e9747ab5211460e8dcc5e81d97e567152a0b710 Mon Sep 17 00:00:00 2001 From: Kevin May Date: Thu, 6 Jul 2023 14:34:35 +0100 Subject: IVGCVSW-7848 Add cache size check to Support Library * Fix for 2 VTS tests named CacheSavingAndRetrievalNonZeroOffset Signed-off-by: Kevin May Change-Id: Id8e02b6383be5706311583aab3f507b5bb43c0bb --- shim/sl/canonical/ArmnnDriverImpl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shim/sl/canonical/ArmnnDriverImpl.cpp b/shim/sl/canonical/ArmnnDriverImpl.cpp index 0f7888bb4b..060dd5a252 100644 --- a/shim/sl/canonical/ArmnnDriverImpl.cpp +++ b/shim/sl/canonical/ArmnnDriverImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -400,6 +400,11 @@ GeneralResult ArmnnDriverImpl::PrepareArmnnModelFromCache( pread(*dataCacheHandle[0], hashValue.data(), hashValue.size(), 0); // Read the model + if (cachedDataSize < hashValue.size()) + { + return NN_ERROR(ErrorStatus::GENERAL_FAILURE) + << "ArmnnDriverImpl::prepareModelFromCache(): cachedDataSize is less than hashValue!"; + } std::vector dataCacheData(cachedDataSize - hashValue.size()); pread(*dataCacheHandle[0], dataCacheData.data(), dataCacheData.size(), hashValue.size()); auto calculatedHashValue = Hash(dataCacheData); -- cgit v1.2.1