]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
cmdmon: fix handling of packets from unbound Unix sockets
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 19 Aug 2015 13:52:36 +0000 (15:52 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Aug 2015 12:35:40 +0000 (14:35 +0200)
When a packet is received from an unbound Unix domain socket, recvfrom()
may return with zero addrlen.

cmdmon.c

index 3af3d9c3a3f145ed5f1e29121c1c2ad6e3fc2555..2375ff328f9c916201d9a5722b76a59c6ac08c8c 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -1558,8 +1558,11 @@ read_from_cmd_socket(void *anything)
     return;
   }
 
-  if (from_length > sizeof (where_from))
-    LOG_FATAL(LOGF_CmdMon, "Truncated source address");
+  if (from_length > sizeof (where_from) ||
+      from_length <= sizeof (where_from.sa.sa_family)) {
+    DEBUG_LOG(LOGF_CmdMon, "Read command packet without source address");
+    return;
+  }
 
   read_length = status;
 
@@ -1582,11 +1585,9 @@ read_from_cmd_socket(void *anything)
       break;
 #endif
     case IPADDR_UNSPEC:
-      /* Unix domain socket */
-      if (where_from.sa.sa_family != AF_UNIX) {
-        DEBUG_LOG(LOGF_CmdMon, "Read command packet with no address");
+      /* This should be the Unix domain socket */
+      if (where_from.sa.sa_family != AF_UNIX)
         return;
-      }
       assert(sock_fd == sock_fdu);
       localhost = 1;
       break;