]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3912] Avoid rare math errors in ntptrace. <brian.utterback@oracle.com>
authorHarlan Stenn <stenn@ntp.org>
Wed, 17 Apr 2024 06:06:36 +0000 (01:06 -0500)
committerHarlan Stenn <stenn@ntp.org>
Wed, 17 Apr 2024 06:06:36 +0000 (01:06 -0500)
bk: 661f66ec8DfezcxFNYtuevJ8HLl0uQ

ChangeLog
scripts/ntptrace/ntptrace.in

index a7715b492d72ec597455012731a73300ad952b62..019db478ad570d4804d1c01b370559e11e88f482 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
              stepped. <hart@ntp.org>
 * [Bug 3913] Avoid duplicate IPv6 link-local manycast associations.
              <hart@ntp.org>
+* [Bug 3912] Avoid rare math errors in ntptrace.  <brian.utterback@oracle.com>
 * [Bug 3909] Do not select multicast local address for unicast peer.
              <hart@ntp.org>
 * [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe.
index e9439773b85fb8dc0057eb1a0c7973a1161dc89f..d92e0796391dec69e029ce72e58bbfc33bbd4030 100755 (executable)
@@ -7,6 +7,7 @@ use 5.006_000;
 use strict;
 use lib "@PERLLIBDIR@";
 use NTP::Util qw(ntp_read_vars do_dns);
+use Scalar::Util qw(looks_like_number);
 
 exit run(@ARGV) unless caller;
 
@@ -60,7 +61,16 @@ sub get_info {
     return if not defined $info;
     return if not exists $info->{stratum};
 
+    if (not (exists $info->{offset} && looks_like_number($info->{offset}))) {
+        $info->{offset} = "NaN";
+    }
     $info->{offset} /= 1000;
+    if (not (exists $info->{rootdisp} && looks_like_number($info->{rootdisp}))) {
+        $info->{rootdisp} = "NaN";
+    }
+    if (not (exists $info->{rootdelay} && looks_like_number($info->{rootdelay}))) {
+        $info->{rootdelay} = "NaN";
+    }
     $info->{syncdistance} = ($info->{rootdisp} + ($info->{rootdelay} / 2)) / 1000;
 
     return %$info;