Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

otel-dest: fix crash when message contains GSockAddrUnix #328

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/gsockaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,17 @@ g_sockaddr_inet_or_inet6_new(const gchar *name, guint16 port)
return addr;
}

gboolean
g_sockaddr_inet_or_inet6_check(GSockAddr *a)
{
#if SYSLOG_NG_ENABLE_IPV6
if (G_UNLIKELY(g_sockaddr_inet6_check(a)))
return TRUE;
#endif

return g_sockaddr_inet_check(a);
}

/* AF_UNIX socket address */

/*+
Expand Down
1 change: 1 addition & 0 deletions lib/gsockaddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ gboolean g_sockaddr_inet6_is_v4_mapped(GSockAddr *s);
#endif

GSockAddr *g_sockaddr_inet_or_inet6_new(const gchar *name, guint16 port);
gboolean g_sockaddr_inet_or_inet6_check(GSockAddr *a);

GSockAddr *g_sockaddr_unix_new(const gchar *name);
GSockAddr *g_sockaddr_unix_new2(struct sockaddr_un *s_un, int sunlen);
Expand Down
4 changes: 2 additions & 2 deletions modules/grpc/otel/otel-protobuf-formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ ProtobufFormatter::set_syslog_ng_addresses(LogMessage *msg, LogRecord &log_recor
{
/* source address */

if (msg->saddr)
if (msg->saddr && g_sockaddr_inet_or_inet6_check(msg->saddr))
{
KeyValue *sa = log_record.add_attributes();
sa->set_key("sa");
set_syslog_ng_address_attrs(msg->saddr, sa->mutable_value()->mutable_kvlist_value(), false);
}

if (msg->daddr)
if (msg->daddr && g_sockaddr_inet_or_inet6_check(msg->daddr))
{
/* dest address */
KeyValue *da = log_record.add_attributes();
Expand Down
Loading