From 1a126325eb26decfe4d3bb64c6ec1c27cafb8c73 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 17 Dec 2018 15:30:23 +0100 Subject: [PATCH] timesync: fix serialization of IP address Fixes: #11169 --- src/timesync/timesyncd-bus.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/timesync/timesyncd-bus.c b/src/timesync/timesyncd-bus.c index c945c3bf7be..5a5896f0b77 100644 --- a/src/timesync/timesyncd-bus.c +++ b/src/timesync/timesyncd-bus.c @@ -80,6 +80,8 @@ static int property_get_current_server_address( if (!a) return sd_bus_message_append(reply, "(iay)", AF_UNSPEC, 0); + assert(IN_SET(a->sockaddr.sa.sa_family, AF_INET, AF_INET6)); + r = sd_bus_message_open_container(reply, 'r', "iay"); if (r < 0) return r; @@ -88,7 +90,9 @@ static int property_get_current_server_address( if (r < 0) return r; - r = sd_bus_message_append_array(reply, 'y', &a->sockaddr.in.sin_addr, FAMILY_ADDRESS_SIZE(a->sockaddr.sa.sa_family)); + r = sd_bus_message_append_array(reply, 'y', + a->sockaddr.sa.sa_family == AF_INET ? (void*) &a->sockaddr.in.sin_addr : (void*) &a->sockaddr.in6.sin6_addr, + FAMILY_ADDRESS_SIZE(a->sockaddr.sa.sa_family)); if (r < 0) return r;