From 3d6756181e45ca59ccf2615ce997d36b450c13d6 Mon Sep 17 00:00:00 2001 From: Peguen <73380451+Peguen@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:52:24 +0200 Subject: [PATCH] [protobuf] Removed size check on cpp message types in protobuf reflection. (#1730) Empty message fields are visible, e.g. in eCAL monitor protobuf reflection plugin --- contrib/ecalproto/src/ecal_proto_decoder.cpp | 12 ++++-------- .../cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/contrib/ecalproto/src/ecal_proto_decoder.cpp b/contrib/ecalproto/src/ecal_proto_decoder.cpp index d5012e8c8e..5ea9ee625f 100644 --- a/contrib/ecalproto/src/ecal_proto_decoder.cpp +++ b/contrib/ecalproto/src/ecal_proto_decoder.cpp @@ -270,10 +270,8 @@ namespace protobuf // do not process default messages to avoid infinite recursions. std::vector msg_fields; msg.GetReflection()->ListFields(msg, &msg_fields); - if (msg_fields.size() > 0) - { - ProcProtoMsg(msg, name.str(), complete_message_name, true, fnum); - } + + ProcProtoMsg(msg, name.str(), complete_message_name, true, fnum); } } } @@ -284,10 +282,8 @@ namespace protobuf // do not process default messages to avoid infinite recursions. std::vector msg_fields; msg.GetReflection()->ListFields(msg, &msg_fields); - if (msg_fields.size() > 0) - { - ProcProtoMsg(msg, field->name(), complete_message_name, false, field->number()); - } + + ProcProtoMsg(msg, field->name(), complete_message_name, false, field->number()); } } break; diff --git a/samples/cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp b/samples/cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp index f597681421..1acc464824 100644 --- a/samples/cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp +++ b/samples/cpp/pubsub/protobuf/proto_dyn/src/proto_dyn.cpp @@ -243,10 +243,8 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref // do not process default messages to avoid infinite recursions. std::vector msg_fields; msg.GetReflection()->ListFields(msg, &msg_fields); - if (msg_fields.size() > 0) - { - ProcProtoMsg(msg, prefix); - } + + ProcProtoMsg(msg, prefix); } } else @@ -258,10 +256,8 @@ void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& pref // do not process default messages to avoid infinite recursions. std::vector msg_fields; msg.GetReflection()->ListFields(msg, &msg_fields); - if (msg_fields.size() > 0) - { - ProcProtoMsg(msg, prefix); - } + + ProcProtoMsg(msg, prefix); } } break;