diff options
author | Colm Donelan <colm.donelan@arm.com> | 2024-02-12 17:05:52 +0000 |
---|---|---|
committer | Colm Donelan <colm.donelan@arm.com> | 2024-02-12 17:18:16 +0000 |
commit | 73036eb7e47badf393f566778fb934856c7af26b (patch) | |
tree | 77988af8a367847e6bca39cd44e14c4c00ff6807 /profiling/server/src/basePipeServer | |
parent | dce338221f5c4716f8e06f67c518af4afc75db08 (diff) | |
download | armnn-73036eb7e47badf393f566778fb934856c7af26b.tar.gz |
IVGCVSW-8284 Out of bounds access error in BasePipeServer.cpp
Change-Id: I52c97f003cc8b26aae7e1f5037c79f0d05bd7143
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
Diffstat (limited to 'profiling/server/src/basePipeServer')
-rw-r--r-- | profiling/server/src/basePipeServer/BasePipeServer.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/profiling/server/src/basePipeServer/BasePipeServer.cpp b/profiling/server/src/basePipeServer/BasePipeServer.cpp index 96e8e24a2c..08d9126fb9 100644 --- a/profiling/server/src/basePipeServer/BasePipeServer.cpp +++ b/profiling/server/src/basePipeServer/BasePipeServer.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2020, 2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -11,7 +11,7 @@ #include <iostream> #include <vector> #include <iomanip> -#include <string.h> +#include <string> namespace arm { @@ -87,8 +87,15 @@ bool BasePipeServer::WaitForStreamMetaData() uint32_t metaDataLength = ToUint32(&header[4], m_Endianness) - 4; // Read the entire packet. std::vector<uint8_t> packetData(metaDataLength); - if (metaDataLength != - arm::pipe::numeric_cast<uint32_t>(arm::pipe::Read(m_ClientConnection, packetData.data(), metaDataLength))) + long bytesRead = arm::pipe::Read(m_ClientConnection, packetData.data(), metaDataLength); + // On Socket error Read will return -1. + if (bytesRead < 0) + { + std::cerr << ": Socket error: " << strerror(errno) << std::endl; + return false; + } + // bytesRead cannot be negative here. + if (metaDataLength != arm::pipe::numeric_cast<uint32_t>(bytesRead)) { std::cerr << ": Protocol read error. Data length mismatch." << std::endl; return false; |