From 489a27f70d41edcc29e60d4dc3e7cbd9452c72a0 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 20 May 2015 22:13:32 +0300 Subject: [PATCH] BasicFileServer::handleRead() error handling fix --- libuavcan/include/uavcan/protocol/file_server.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libuavcan/include/uavcan/protocol/file_server.hpp b/libuavcan/include/uavcan/protocol/file_server.hpp index d525b70156..ef6008766c 100644 --- a/libuavcan/include/uavcan/protocol/file_server.hpp +++ b/libuavcan/include/uavcan/protocol/file_server.hpp @@ -136,6 +136,11 @@ class BasicFileServer resp.error.value = backend_.read(req.path.path, req.offset, resp.data.begin(), inout_size); + if (resp.error.value != protocol::file::Error::OK) + { + inout_size = 0; + } + if (inout_size > resp.data.capacity()) { UAVCAN_ASSERT(0);