]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: avoid passing uninitialized address to format_name()
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Jun 2023 14:10:46 +0000 (16:10 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 8 Jun 2023 13:56:19 +0000 (15:56 +0200)
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

index 80bc7c006f7ef9324e53ae57c05a1292c2525dd1..0790daf8cc343fc0b8e14b997191f22af4f204b6 100644 (file)
--- 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: