]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: log error when local refid is unknown in orphan mode
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 1 Apr 2016 07:37:49 +0000 (09:37 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 1 Apr 2016 07:37:49 +0000 (09:37 +0200)
sources.c

index df3f7a0ba23ca42926f9e23388f43ecb505c8aaf..b3a2e97d430e3a3efb77db9ed96ff60c7261c412 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -731,13 +731,17 @@ SRC_SelectSource(SRC_Instance updated_inst)
   }
 
   /* If no selectable source is available, consider the orphan source */
-  if (!n_sel_sources && orphan_source != INVALID_SOURCE &&
-      sources[orphan_source]->ref_id <
-        NSR_GetLocalRefid(sources[orphan_source]->ip_addr)) {
-    sources[orphan_source]->status = SRC_OK;
-    n_sel_sources = 1;
-    DEBUG_LOG(LOGF_Sources, "selecting orphan refid=%"PRIx32,
-              sources[orphan_source]->ref_id);
+  if (!n_sel_sources && orphan_source != INVALID_SOURCE) {
+    uint32_t local_ref_id = NSR_GetLocalRefid(sources[orphan_source]->ip_addr);
+
+    if (!local_ref_id) {
+      LOG(LOGS_ERR, LOGF_Sources, "Unknown local refid in orphan mode");
+    } else if (sources[orphan_source]->ref_id < local_ref_id) {
+      sources[orphan_source]->status = SRC_OK;
+      n_sel_sources = 1;
+      DEBUG_LOG(LOGF_Sources, "selecting orphan refid=%"PRIx32,
+                sources[orphan_source]->ref_id);
+    }
   }
 
   for (i = 0; i < n_sources; i++) {