]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: improve check for PTP socket
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 24 Nov 2021 14:05:15 +0000 (15:05 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 24 Nov 2021 14:07:04 +0000 (15:07 +0100)
Check for INVALID_SOCK_FD in case the PTP port is enabled, but opening
one of the PTP sockets failed.

ntp_io.c

index 077a7cff16dcfdf5a168bcb08f617c367bb3bb66..b9d5f13ad4644dacba783964958f31a22c0372eb 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -332,7 +332,8 @@ NIO_OpenServerSocket(NTP_Remote_Address *remote_addr)
 static int
 is_ptp_socket(int sock_fd)
 {
-  return ptp_port > 0 && (sock_fd == ptp_sock_fd4 || sock_fd == ptp_sock_fd6);
+  return ptp_port > 0 && sock_fd != INVALID_SOCK_FD &&
+    (sock_fd == ptp_sock_fd4 || sock_fd == ptp_sock_fd6);
 }
 
 /* ================================================== */