From c11a0529557d48c1471c7620319ca527c6366585 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 5 Jun 2023 16:10:46 +0200 Subject: [PATCH] client: avoid passing uninitialized address to format_name() The clang memory sanitizer seems to trigger on an uninitialized value passed to format_name() when the source is a refclock, even though the value is not used for anything. Pass 0 in this case to avoid the error. --- client.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index 80bc7c0..0790daf 100644 --- a/client.c +++ b/client.c @@ -1979,7 +1979,7 @@ process_cmd_sources(char *line) IPAddr ip_addr; uint32_t i, mode, n_sources; char name[256], mode_ch, state_ch; - int all, verbose; + int all, verbose, ref; parse_sources_options(line, &all, &verbose); @@ -2016,9 +2016,8 @@ process_cmd_sources(char *line) if (!all && ip_addr.family == IPADDR_ID) continue; - format_name(name, sizeof (name), 25, - mode == RPY_SD_MD_REF && ip_addr.family == IPADDR_INET4, - ip_addr.addr.in4, 1, &ip_addr); + ref = mode == RPY_SD_MD_REF && ip_addr.family == IPADDR_INET4; + format_name(name, sizeof (name), 25, ref, ref ? ip_addr.addr.in4 : 0, 1, &ip_addr); switch (mode) { case RPY_SD_MD_CLIENT: