diff options
author | Colm Donelan <colm.donelan@arm.com> | 2024-02-12 17:05:52 +0000 |
---|---|---|
committer | John Mcloughlin <john.mcloughlin@arm.com> | 2024-02-13 14:50:05 +0000 |
commit | 90a68246225c80247dd7a26f7de85430f4f5c94d (patch) | |
tree | 20419d7e9599a58ce4d339a4e0a2abb7b8b3eff6 | |
parent | 3c3da96b88cd23566d6a2dcef75ae269fcc4d5a3 (diff) | |
download | armnn-90a68246225c80247dd7a26f7de85430f4f5c94d.tar.gz |
IVGCVSW-8284 Out of bounds access error in BasePipeServer.cpp
Change-Id: I52c97f003cc8b26aae7e1f5037c79f0d05bd7143
Signed-off-by: Colm Donelan <colm.donelan@arm.com>
-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; |