]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: don't save or load dumpfiles for unknown addresses
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 24 Feb 2020 17:05:09 +0000 (18:05 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Mar 2020 15:02:15 +0000 (16:02 +0100)
Don't open a dumpfile for reading or writing if the NTP source doesn't
have a real address.

Fixes: d7e3ad17ff7a ("ntp: create sources for unresolved addresses")
sources.c

index 7ed34a55d22fac3d00406a89bafe4b389d32f6e4..7193491233093ddf1928864ea8c98e653b041e12 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -1161,10 +1161,12 @@ FILE *open_dumpfile(SRC_Instance inst, char mode)
   }
 
   /* Include IP address in the name for NTP sources, or reference ID in hex */
-  if (inst->type == SRC_NTP)
+  if (inst->type == SRC_NTP && UTI_IsIPReal(inst->ip_addr))
     snprintf(filename, sizeof (filename), "%s", source_to_string(inst));
-  else
+  else if (inst->type == SRC_REFCLOCK)
     snprintf(filename, sizeof (filename), "refid:%08"PRIx32, inst->ref_id);
+  else
+    return NULL;
 
   return UTI_OpenFile(dumpdir, filename, ".dat", mode, 0644);
 }