File 5408.patch of Package syslog-ng
From 1f22d8a3e92e5ef1cd724b11d19a638a59530eed Mon Sep 17 00:00:00 2001
From: Hofi <hofione@gmail.com>
Date: Thu, 19 Jun 2025 17:29:12 +0200
Subject: [PATCH] grpc: add workarounds of protobuf 30 changes that can be
compiled with the older versions as well
Signed-off-by: Hofi <hofione@gmail.com>
Signed-off-by: Kovacs, Gergo Ferenc <gergo.kovacs@quest.com>
---
modules/grpc/bigquery/bigquery-dest.cpp | 3 ++-
modules/grpc/otel/filterx/object-otel-array.cpp | 6 ++++--
modules/grpc/otel/filterx/object-otel-kvlist.cpp | 6 ++++--
modules/grpc/otel/filterx/otel-field.cpp | 8 +++++---
modules/grpc/otel/filterx/protobuf-field.cpp | 13 ++++++++-----
modules/grpc/otel/filterx/protobuf-field.hpp | 2 +-
6 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/modules/grpc/bigquery/bigquery-dest.cpp b/modules/grpc/bigquery/bigquery-dest.cpp
index d3745e4c7..6042d91ac 100644
--- a/modules/grpc/bigquery/bigquery-dest.cpp
+++ b/modules/grpc/bigquery/bigquery-dest.cpp
@@ -316,7 +316,8 @@ DestinationDriver::load_protobuf_schema()
LogTemplate *value = (LogTemplate *) current_value->data;
- this->fields.push_back(Field{field->name(), (google::protobuf::FieldDescriptorProto::Type) field->type(), value});
+ std::string name(field->name());
+ this->fields.push_back(Field{name.c_str(), (google::protobuf::FieldDescriptorProto::Type) field->type(), value});
this->fields[i].field_desc = field;
current_value = current_value->next;
diff --git a/modules/grpc/otel/filterx/object-otel-array.cpp b/modules/grpc/otel/filterx/object-otel-array.cpp
index ab2b8de7b..c21feca99 100644
--- a/modules/grpc/otel/filterx/object-otel-array.cpp
+++ b/modules/grpc/otel/filterx/object-otel-array.cpp
@@ -354,9 +354,11 @@ OtelArrayField::FilterXObjectSetter(google::protobuf::Message *message, ProtoRef
if (filterx_object_is_type(object, &FILTERX_TYPE_NAME(list)))
return _set_array_field_from_list(message, reflectors, object, assoc_object);
+ std::string name(reflectors.fieldDescriptor->name());
+ std::string type_name(reflectors.fieldDescriptor->type_name());
msg_error("otel-array: Failed to convert field, type is unsupported",
- evt_tag_str("field", reflectors.fieldDescriptor->name().c_str()),
- evt_tag_str("expected_type", reflectors.fieldDescriptor->type_name()),
+ evt_tag_str("field", name.c_str()),
+ evt_tag_str("expected_type", type_name.c_str()),
evt_tag_str("type", object->type->name));
return false;
}
diff --git a/modules/grpc/otel/filterx/object-otel-kvlist.cpp b/modules/grpc/otel/filterx/object-otel-kvlist.cpp
index 20e02d59f..fbfca03b2 100644
--- a/modules/grpc/otel/filterx/object-otel-kvlist.cpp
+++ b/modules/grpc/otel/filterx/object-otel-kvlist.cpp
@@ -482,9 +482,11 @@ OtelKVListField::FilterXObjectSetter(google::protobuf::Message *message, ProtoRe
if (filterx_object_is_type(object, &FILTERX_TYPE_NAME(dict)))
return _set_kvlist_field_from_dict(message, reflectors, object, assoc_object);
+ std::string name(reflectors.fieldDescriptor->name());
+ std::string type_name(reflectors.fieldDescriptor->type_name());
msg_error("otel-kvlist: Failed to convert field, type is unsupported",
- evt_tag_str("field", reflectors.fieldDescriptor->name().c_str()),
- evt_tag_str("expected_type", reflectors.fieldDescriptor->type_name()),
+ evt_tag_str("field", name.c_str()),
+ evt_tag_str("expected_type", type_name.c_str()),
evt_tag_str("type", object->type->name));
return false;
}
diff --git a/modules/grpc/otel/filterx/otel-field.cpp b/modules/grpc/otel/filterx/otel-field.cpp
index 947bb0538..a627bed1f 100644
--- a/modules/grpc/otel/filterx/otel-field.cpp
+++ b/modules/grpc/otel/filterx/otel-field.cpp
@@ -99,8 +99,9 @@ AnyField::FilterXObjectGetter(Message *message, ProtoReflectors reflectors)
return this->FilterXObjectDirectGetter(anyValue);
}
+ std::string name(reflectors.fieldDescriptor->name());
msg_error("otel-field: Unexpected protobuf field type",
- evt_tag_str("name", reflectors.fieldDescriptor->name().c_str()),
+ evt_tag_str("name", name.c_str()),
evt_tag_int("type", reflectors.fieldType));
return nullptr;
}
@@ -258,7 +259,8 @@ public:
return true;
}
- return protobuf_converter_by_type(reflectors.fieldDescriptor->type())->Set(message, reflectors.fieldDescriptor->name(),
+ return protobuf_converter_by_type(reflectors.fieldDescriptor->type())->Set(message,
+ std::string(reflectors.fieldDescriptor->name()),
object, assoc_object);
}
};
@@ -313,7 +315,7 @@ ProtobufField *syslogng::grpc::otel::otel_converter_by_type(FieldDescriptor::Typ
ProtobufField *syslogng::grpc::otel::otel_converter_by_field_descriptor(const FieldDescriptor *fd)
{
- const std::string &fieldName = fd->name();
+ const std::string fieldName(fd->name());
if (fieldName.compare("time_unix_nano") == 0 ||
fieldName.compare("observed_time_unix_nano") == 0)
{
diff --git a/modules/grpc/otel/filterx/protobuf-field.cpp b/modules/grpc/otel/filterx/protobuf-field.cpp
index e6bbcd54d..5faf67a25 100644
--- a/modules/grpc/otel/filterx/protobuf-field.cpp
+++ b/modules/grpc/otel/filterx/protobuf-field.cpp
@@ -42,9 +42,11 @@ using namespace syslogng::grpc::otel;
void
log_type_error(ProtoReflectors reflectors, const char *type)
{
+ std::string name(reflectors.fieldDescriptor->name());
+ std::string type_name(reflectors.fieldDescriptor->type_name());
msg_error("protobuf-field: Failed to convert field, type is unsupported",
- evt_tag_str("field", reflectors.fieldDescriptor->name().c_str()),
- evt_tag_str("expected_type", reflectors.fieldDescriptor->type_name()),
+ evt_tag_str("field", name.c_str()),
+ evt_tag_str("expected_type", type_name.c_str()),
evt_tag_str("type", type));
}
@@ -159,8 +161,9 @@ public:
uint64_t val = reflectors.reflection->GetUInt64(*message, reflectors.fieldDescriptor);
if (val > INT64_MAX)
{
+ std::string name(reflectors.fieldDescriptor->name());
msg_error("protobuf-field: exceeding FilterX number value range",
- evt_tag_str("field", reflectors.fieldDescriptor->name().c_str()),
+ evt_tag_str("field", name.c_str()),
evt_tag_long("range_min", INT64_MIN),
evt_tag_long("range_max", INT64_MAX),
evt_tag_printf("current", "%" G_GUINT64_FORMAT, val));
@@ -218,8 +221,8 @@ public:
const gchar *json_literal = filterx_json_to_json_literal(object);
if (!json_literal)
{
- msg_error("protobuf-field: json marshal error",
- evt_tag_str("field", reflectors.fieldDescriptor->name().c_str()));
+ std::string name(reflectors.fieldDescriptor->name());
+ msg_error("protobuf-field: json marshal error", evt_tag_str("field", name.c_str()));
return false;
}
reflectors.reflection->SetString(message, reflectors.fieldDescriptor, json_literal);
diff --git a/modules/grpc/otel/filterx/protobuf-field.hpp b/modules/grpc/otel/filterx/protobuf-field.hpp
index 7bc8c5716..709564245 100644
--- a/modules/grpc/otel/filterx/protobuf-field.hpp
+++ b/modules/grpc/otel/filterx/protobuf-field.hpp
@@ -49,7 +49,7 @@ struct ProtoReflectors
this->descriptor = message.GetDescriptor();
if (!this->reflection || !this->descriptor)
{
- std::string error_msg = "unable to access reflector for protobuf message: " + message.GetTypeName();
+ std::string error_msg = "unable to access reflector for protobuf message: " + std::string(message.GetTypeName());
throw std::invalid_argument(error_msg);
}
this->fieldDescriptor = this->descriptor->FindFieldByName(fieldName);
--
2.50.0