From 2c99f61bdf370c4f3294a128c0630957cb06eb18 Mon Sep 17 00:00:00 2001 From: Rex Schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:41:52 +0200 Subject: [PATCH] [core] serialization-decode-error-handling (#1673) --- ecal/core/src/serialization/ecal_serialize_logging.cpp | 4 +++- ecal/core/src/serialization/ecal_serialize_monitoring.cpp | 1 + ecal/core/src/serialization/ecal_serialize_sample_payload.cpp | 3 ++- .../src/serialization/ecal_serialize_sample_registration.cpp | 4 +++- ecal/core/src/serialization/ecal_serialize_service.cpp | 4 +++- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ecal/core/src/serialization/ecal_serialize_logging.cpp b/ecal/core/src/serialization/ecal_serialize_logging.cpp index 8cc69fdfe3..ef67992538 100644 --- a/ecal/core/src/serialization/ecal_serialize_logging.cpp +++ b/ecal/core/src/serialization/ecal_serialize_logging.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,6 +157,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_LogMessage_fields, &pb_log_message)) { std::cerr << "NanoPb eCAL::Logging::LogMessage decode failed: " << pb_istream.errmsg << '\n'; + return false; } /////////////////////////////////////////////// @@ -293,6 +294,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_LogMessageList_fields, &pb_log_message_list)) { std::cerr << "NanoPb eCAL::Logging::LogMessageList decode failed: " << pb_istream.errmsg << '\n'; + return false; } return true; diff --git a/ecal/core/src/serialization/ecal_serialize_monitoring.cpp b/ecal/core/src/serialization/ecal_serialize_monitoring.cpp index bdfacd137e..5e0bd04a52 100644 --- a/ecal/core/src/serialization/ecal_serialize_monitoring.cpp +++ b/ecal/core/src/serialization/ecal_serialize_monitoring.cpp @@ -894,6 +894,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_Monitoring_fields, &pb_mon_message)) { std::cerr << "NanoPb eCAL::Monitoring::SMonitoring decode failed: " << pb_istream.errmsg << '\n'; + return false; } return true; diff --git a/ecal/core/src/serialization/ecal_serialize_sample_payload.cpp b/ecal/core/src/serialization/ecal_serialize_sample_payload.cpp index 1f8caf4106..45e2b92006 100644 --- a/ecal/core/src/serialization/ecal_serialize_sample_payload.cpp +++ b/ecal/core/src/serialization/ecal_serialize_sample_payload.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,6 +168,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_Sample_fields, &pb_sample)) { std::cerr << "NanoPb eCAL::Payload::Sample decode failed: " << pb_istream.errmsg << '\n'; + return false; } /////////////////////////////////////////////// diff --git a/ecal/core/src/serialization/ecal_serialize_sample_registration.cpp b/ecal/core/src/serialization/ecal_serialize_sample_registration.cpp index d758f79e7e..c4bfffd96a 100644 --- a/ecal/core/src/serialization/ecal_serialize_sample_registration.cpp +++ b/ecal/core/src/serialization/ecal_serialize_sample_registration.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -430,6 +430,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_Sample_fields, &pb_sample)) { std::cerr << "NanoPb eCAL::Registration::Sample decode failed: " << pb_istream.errmsg << '\n'; + return false; } /////////////////////////////////////////////// @@ -568,6 +569,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_SampleList_fields, &pb_sample_list)) { std::cerr << "NanoPb eCAL::Registration::Sample decode failed: " << pb_istream.errmsg << '\n'; + return false; } return true; diff --git a/ecal/core/src/serialization/ecal_serialize_service.cpp b/ecal/core/src/serialization/ecal_serialize_service.cpp index 0a9bb72337..9bf6260d51 100644 --- a/ecal/core/src/serialization/ecal_serialize_service.cpp +++ b/ecal/core/src/serialization/ecal_serialize_service.cpp @@ -1,6 +1,6 @@ /* ========================= eCAL LICENSE ================================= * - * Copyright (C) 2016 - 2019 Continental Corporation + * Copyright (C) 2016 - 2024 Continental Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,6 +144,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_Request_fields, &pb_request)) { std::cerr << "NanoPb eCAL::Service::Request decode failed: " << pb_istream.errmsg << '\n'; + return false; } /////////////////////////////////////////////// @@ -270,6 +271,7 @@ namespace if (!pb_decode(&pb_istream, eCAL_pb_Response_fields, &pb_response)) { std::cerr << "NanoPb eCAL::Service::Response decode failed: " << pb_istream.errmsg << '\n'; + return false; } ///////////////////////////////////////////////